Skip to content

Commit 6400946

Browse files
committed
docs: add docs
1 parent d93340e commit 6400946

File tree

3 files changed

+38
-1
lines changed

3 files changed

+38
-1
lines changed

user_guide_src/source/changelogs/v4.4.0.rst

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,11 @@ Helpers and Functions
5858

5959
Others
6060
======
61-
- **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.
6261

62+
- **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.
63+
- **Auto Routing (Improved)**: Now you can use URI without a method name like
64+
``product/15`` where ``15`` is an arbitrary number.
65+
See :ref:`controller-default-method-fallback` for details.
6366

6467
Message Changes
6568
***************

user_guide_src/source/incoming/controllers.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,29 @@ Your method will be passed URI segments 3 and 4 (``'sandals'`` and ``'123'``):
263263

264264
.. literalinclude:: controllers/022.php
265265

266+
.. _controller-default-method-fallback:
267+
268+
Default Method Fallback
269+
=======================
270+
271+
.. versionadded:: 4.4.0
272+
273+
If the controller method corresponding to the URI segment of the method name
274+
does not exist, and if the default method is defined, the URI segments are
275+
passed to the default method for execution.
276+
277+
.. literalinclude:: controllers/024.php
278+
279+
Load the following URL::
280+
281+
example.com/index.php/product/15/edit
282+
283+
The method will be passed URI segments 2 and 3 (``'15'`` and ``'edit'``):
284+
285+
.. note:: If there are more parameters in the URI than the method parameters,
286+
Auto Routing (Improved) does not execute the method, and it results in 404
287+
Not Found.
288+
266289
Defining a Default Controller
267290
=============================
268291

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
<?php
2+
3+
namespace App\Controllers;
4+
5+
class Product extends BaseController
6+
{
7+
public function getIndex($id = null, $action = '')
8+
{
9+
// ...
10+
}
11+
}

0 commit comments

Comments
 (0)