Skip to content

Commit e145c19

Browse files
committed
docs: update user guide
1 parent e91af1c commit e145c19

3 files changed

Lines changed: 24 additions & 5 deletions

File tree

user_guide_src/source/general/common_functions.rst

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -367,16 +367,18 @@ Miscellaneous Functions
367367

368368
.. php:function:: route_to($method[, ...$params])
369369
370-
:param string $method: The named route alias, or name of the controller/method to match.
371-
:param int|string $params: One or more parameters to be passed to be matched in the route. The last parameter allows you to set the locale.
370+
:param string $method: Route name or Controller::method
371+
:param int|string ...$params: One or more parameters to be passed to the route. The last parameter allows you to set the locale.
372+
:returns: a route (URI path)
373+
:rtype: string
372374

373375
.. note:: This function requires the controller/method to have a route defined in **app/Config/routes.php**.
374376

375377
Generates a route for you based on a controller::method combination. Will take parameters into effect, if provided.
376378

377379
.. literalinclude:: common_functions/009.php
378380

379-
Generates a route for you based on a named route alias.
381+
Generates a route for you based on a route name.
380382

381383
.. literalinclude:: common_functions/010.php
382384

user_guide_src/source/helpers/url_helper.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -361,8 +361,8 @@ The following functions are available:
361361

362362
.. php:function:: url_to($controller[, ...$args])
363363
364-
:param string $controller: Named route or Controller::method
365-
:param mixed ...$args: One or more parameters to be passed to the route
364+
:param string $controller: Route name or Controller::method
365+
:param mixed ...$args: One or more parameters to be passed to the route. The last parameter allows you to set the locale.
366366
:returns: Absolute URL
367367
:rtype: string
368368

@@ -380,6 +380,10 @@ The following functions are available:
380380
This is useful because you can still change your routes after putting links
381381
into your views.
382382

383+
Since v4.3.0, when you use ``{locale}`` in your route, you can optionally specify the locale value as the last parameter.
384+
385+
.. literalinclude:: url_helper/025.php
386+
383387
For full details, see the :ref:`reverse-routing` and :ref:`using-named-routes`.
384388

385389
.. php:function:: url_is($path)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<?php
2+
3+
// The route is defined as:
4+
$routes->add(
5+
'{locale}/users/(:num)/gallery/(:num)',
6+
'Galleries::showUserGallery/$1/$2',
7+
['as' => 'user_gallery']
8+
);
9+
10+
?>
11+
12+
<a href="<?= url_to('user_gallery', 15, 12, 'en') ?>">View Gallery</a>
13+
<!-- Result: 'http://example.com/en/users/15/gallery/12' -->

0 commit comments

Comments
 (0)