Skip to content

Commit 9eb172e

Browse files
committed
docs: update docs
1 parent b9e68ee commit 9eb172e

File tree

3 files changed

+28
-47
lines changed

3 files changed

+28
-47
lines changed

user_guide_src/source/changelogs/v4.4.0.rst

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,11 +96,10 @@ Others
9696
- **View:** Added optional 2nd parameter ``$saveData`` on ``renderSection()`` to prevent from auto cleans the data after displaying. See :ref:`View Layouts <creating-a-layout>` for details.
9797
- **Auto Routing (Improved)**: Now you can route to Modules.
9898
See :ref:`auto-routing-improved-module-routing` for details.
99-
- **Auto Routing (Improved):** Now you can pass arguments to the the default
100-
controller that is omitted in the URI.
101-
See :ref:`controller-default-controller-fallback` for details.
102-
- **Auto Routing (Improved):** Now you can use URI without a method name like
103-
``product/15`` where ``15`` is an arbitrary number.
99+
- **Auto Routing (Improved):** If a controller is found that corresponds to a URI
100+
segment and that controller does not have a method defined for the URI segment,
101+
the default method will now be executed. This addition allows for more flexible
102+
handling of URIs in auto routing.
104103
See :ref:`controller-default-method-fallback` for details.
105104
- **Filters:** Now you can use Filter Arguments with :ref:`$filters property <filters-filters-filter-arguments>`.
106105
- **Request:** Added ``IncomingRequest::setValidLocales()`` method to set valid locales.

user_guide_src/source/incoming/controllers.rst

Lines changed: 24 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -279,17 +279,33 @@ Your method will be passed URI segments 3 and 4 (``'sandals'`` and ``'123'``):
279279

280280
.. literalinclude:: controllers/022.php
281281

282-
.. _controller-default-controller-fallback:
282+
.. _controller-default-method-fallback:
283283

284-
Default Controller Fallback
285-
===========================
284+
Default Method Fallback
285+
=======================
286286

287287
.. versionadded:: 4.4.0
288288

289+
If the controller method corresponding to the URI segment of the method name
290+
does not exist, and if the default method is defined, the remaining URI segments
291+
are passed to the default method for execution.
292+
293+
.. literalinclude:: controllers/024.php
294+
295+
Load the following URL::
296+
297+
example.com/index.php/product/15/edit
298+
299+
The method will be passed URI segments 2 and 3 (``'15'`` and ``'edit'``):
300+
301+
.. important:: If there are more parameters in the URI than the method parameters,
302+
Auto Routing (Improved) does not execute the method, and it results in 404
303+
Not Found.
304+
289305
If the controller corresponding to the URI segment of the controller name
290306
does not exist, and if the default controller (``Home`` by default) exists in
291-
the directory, the remaining URI segments are passed to the default controller
292-
for execution.
307+
the directory, the remaining URI segments are passed to the default controller's
308+
default method.
293309

294310
For example, when you have the following default controller ``Home`` in the
295311
**app/Controllers/News** directory:
@@ -298,48 +314,19 @@ For example, when you have the following default controller ``Home`` in the
298314

299315
Load the following URL::
300316

301-
example.com/index.php/news/list
317+
example.com/index.php/news/101
302318

303-
The ``News\Home`` controller will be found, and the ``getList()`` method will be
304-
executed.
319+
The ``News\Home`` controller and the default ``getIndex()`` method will be found.
320+
So the default method will be passed URI segments 2 (``'101'``):
305321

306322
.. note:: If there is ``App\Controllers\News`` controller, it takes precedence.
307323
The URI segments are searched sequentially and the first controller found
308324
is used.
309325

310-
Load the following URL::
311-
312-
example.com/index.php/news/101
313-
314-
The default ``getIndex()`` method will be passed URI segments 2 (``'101'``):
315-
316326
.. note:: If there are more parameters in the URI than the method parameters,
317327
Auto Routing (Improved) does not execute the method, and it results in 404
318328
Not Found.
319329

320-
.. _controller-default-method-fallback:
321-
322-
Default Method Fallback
323-
=======================
324-
325-
.. versionadded:: 4.4.0
326-
327-
If the controller method corresponding to the URI segment of the method name
328-
does not exist, and if the default method is defined, the remaining URI segments
329-
are passed to the default method for execution.
330-
331-
.. literalinclude:: controllers/024.php
332-
333-
Load the following URL::
334-
335-
example.com/index.php/product/15/edit
336-
337-
The method will be passed URI segments 2 and 3 (``'15'`` and ``'edit'``):
338-
339-
.. important:: If there are more parameters in the URI than the method parameters,
340-
Auto Routing (Improved) does not execute the method, and it results in 404
341-
Not Found.
342-
343330
Default Controller
344331
==================
345332

user_guide_src/source/incoming/controllers/025.php

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,6 @@
66

77
class Home extends BaseController
88
{
9-
public function getList()
10-
{
11-
// ...
12-
}
13-
149
public function getIndex($id = null)
1510
{
1611
// ...

0 commit comments

Comments
 (0)