Skip to content

Commit

Permalink
Merge pull request #8329 from kenjis/docs-update-routing
Browse files Browse the repository at this point in the history
docs: update sample code in Auto Routing
  • Loading branch information
kenjis authored Dec 14, 2023
2 parents 3d742a3 + 5c4c72c commit f81dd1a
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 24 deletions.
38 changes: 21 additions & 17 deletions user_guide_src/source/incoming/routing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -740,21 +740,22 @@ See :ref:`Auto Routing in Controllers <controller-auto-routing-improved>` for mo
Configuration Options
=====================

These options are available at the top of **app/Config/Routes.php**.
These options are available in the **app/Config/Routing.php** file.

Default Controller
------------------

For Site Root URI
^^^^^^^^^^^^^^^^^

When a user visits the root of your site (i.e., **example.com**) the controller to use is determined by the value set by
the ``setDefaultController()`` method, unless a route exists for it explicitly.
When a user visits the root of your site (i.e., **example.com**) the controller
to use is determined by the value set to the ``$defaultController`` property,
unless a route exists for it explicitly.

The default value for this is ``Home``
which matches the controller at **app/Controllers/Home.php**:
The default value for this is ``Home`` which matches the controller at
**app/Controllers/Home.php**::

.. literalinclude:: routing/047.php
public string $defaultController = 'Home';

For Directory URI
^^^^^^^^^^^^^^^^^
Expand All @@ -775,10 +776,10 @@ This works similar to the default controller setting, but is used to determine t
when a controller is found that matches the URI, but no segment exists for the method. The default value is
``index``.

In this example, if the user were to visit **example.com/products**, and a ``Products`` controller existed, the
``Products::getListAll()`` method would be executed:
In this example, if the user were to visit **example.com/products**, and a ``Products``
controller existed, the ``Products::getListAll()`` method would be executed::

.. literalinclude:: routing/048.php
public string $defaultMethod = 'listAll';

.. important:: You cannot access the controller with the URI of the default method name.
In the example above, you can access **example.com/products**, but if you access **example.com/products/listall**, it will be not found.
Expand Down Expand Up @@ -868,19 +869,22 @@ See :ref:`Auto Routing (Legacy) in Controllers <controller-auto-routing-legacy>`
Configuration Options (Legacy)
==============================

These options are available at the top of **app/Config/Routes.php**.
These options are available in the **app/Config/Routing.php** file.

Default Controller (Legacy)
---------------------------

For Site Root URI (Legacy)
^^^^^^^^^^^^^^^^^^^^^^^^^^

When a user visits the root of your site (i.e., example.com) the controller to use is determined by the value set by
the ``setDefaultController()`` method, unless a route exists for it explicitly. The default value for this is ``Home``
which matches the controller at **app/Controllers/Home.php**:
When a user visits the root of your site (i.e., **example.com**) the controller
to use is determined by the value set to the ``$defaultController`` property,
unless a route exists for it explicitly.

.. literalinclude:: routing/047.php
The default value for this is ``Home`` which matches the controller at
**app/Controllers/Home.php**::

public string $defaultController = 'Home';

For Directory URI (Legacy)
^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand All @@ -898,10 +902,10 @@ This works similar to the default controller setting, but is used to determine t
when a controller is found that matches the URI, but no segment exists for the method. The default value is
``index``.

In this example, if the user were to visit **example.com/products**, and a ``Products`` controller existed, the
``Products::listAll()`` method would be executed:
In this example, if the user were to visit **example.com/products**, and a ``Products``
controller existed, the ``Products::listAll()`` method would be executed::

.. literalinclude:: routing/048.php
public string $defaultMethod = 'listAll';

Confirming Routes
*****************
Expand Down
4 changes: 0 additions & 4 deletions user_guide_src/source/incoming/routing/047.php

This file was deleted.

3 changes: 0 additions & 3 deletions user_guide_src/source/incoming/routing/048.php

This file was deleted.

0 comments on commit f81dd1a

Please sign in to comment.