Skip to content

Commit af3864a

Browse files
committed
docs: update docs
1 parent 1fa1a19 commit af3864a

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
@@ -88,11 +88,10 @@ Others
8888
the ``Content-Disposition: inline`` header to display the file in the browser.
8989
See :ref:`open-file-in-browser` for details.
9090
- **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.
91-
- **Auto Routing (Improved):** Now you can pass arguments to the the default
92-
controller that is omitted in the URI.
93-
See :ref:`controller-default-controller-fallback` for details.
94-
- **Auto Routing (Improved):** Now you can use URI without a method name like
95-
``product/15`` where ``15`` is an arbitrary number.
91+
- **Auto Routing (Improved):** If a controller is found that corresponds to a URI
92+
segment and that controller does not have a method defined for the URI segment,
93+
the default method will now be executed. This addition allows for more flexible
94+
handling of URIs in auto routing.
9695
See :ref:`controller-default-method-fallback` for details.
9796
- **Filters:** Now you can use Filter Arguments with :ref:`$filters property <filters-filters-filter-arguments>`.
9897
- **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
@@ -274,17 +274,33 @@ Your method will be passed URI segments 3 and 4 (``'sandals'`` and ``'123'``):
274274

275275
.. literalinclude:: controllers/022.php
276276

277-
.. _controller-default-controller-fallback:
277+
.. _controller-default-method-fallback:
278278

279-
Default Controller Fallback
280-
===========================
279+
Default Method Fallback
280+
=======================
281281

282282
.. versionadded:: 4.4.0
283283

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

289305
For example, when you have the following default controller ``Home`` in the
290306
**app/Controllers/News** directory:
@@ -293,48 +309,19 @@ For example, when you have the following default controller ``Home`` in the
293309

294310
Load the following URL::
295311

296-
example.com/index.php/news/list
312+
example.com/index.php/news/101
297313

298-
The ``News\Home`` controller will be found, and the ``getList()`` method will be
299-
executed.
314+
The ``News\Home`` controller and the default ``getIndex()`` method will be found.
315+
So the default method will be passed URI segments 2 (``'101'``):
300316

301317
.. note:: If there is ``App\Controllers\News`` controller, it takes precedence.
302318
The URI segments are searched sequentially and the first controller found
303319
is used.
304320

305-
Load the following URL::
306-
307-
example.com/index.php/news/101
308-
309-
The default ``getIndex()`` method will be passed URI segments 2 (``'101'``):
310-
311321
.. note:: If there are more parameters in the URI than the method parameters,
312322
Auto Routing (Improved) does not execute the method, and it results in 404
313323
Not Found.
314324

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

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)