Skip to content

Commit 24acd57

Browse files
committed
Fix up docs.
1 parent 1db4473 commit 24acd57

File tree

1 file changed

+82
-16
lines changed

1 file changed

+82
-16
lines changed

docs/en/url-checkers.rst

Lines changed: 82 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5,47 +5,113 @@ To provide an abstract and framework agnostic solution there are URL
55
checkers implemented that allow you to customize the comparison of the
66
current URL if needed. For example to another frameworks routing.
77

8+
All checkers support single URLs in either string or array format (like ``Router::url()``).
9+
For multiple login URLs, use ``MultiUrlChecker``.
10+
811
Included Checkers
912
=================
1013

14+
CakeUrlChecker
15+
--------------
16+
17+
The default checker when CakePHP is installed. Supports both string URLs and
18+
CakePHP's array-based routing notation. This checker also works with named routes.
19+
20+
Single URL (string):
21+
22+
.. code-block:: php
23+
24+
$service->loadAuthenticator('Authentication.Form', [
25+
'loginUrl' => '/users/login',
26+
]);
27+
28+
Single URL (CakePHP route array):
29+
30+
.. code-block:: php
31+
32+
$service->loadAuthenticator('Authentication.Form', [
33+
'loginUrl' => [
34+
'prefix' => false,
35+
'plugin' => false,
36+
'controller' => 'Users',
37+
'action' => 'login',
38+
],
39+
]);
40+
41+
Options:
42+
43+
- **checkFullUrl**: To compare the full URL, including protocol, host
44+
and port or not. Default is ``false``
45+
1146
DefaultUrlChecker
1247
-----------------
1348

14-
The default checker allows you to compare an URL by regex or string
15-
URLs.
49+
Framework-agnostic checker for string URLs. Supports regex matching.
50+
This is the default when CakePHP is not installed.
51+
52+
.. code-block:: php
53+
54+
$service->loadAuthenticator('Authentication.Form', [
55+
'urlChecker' => 'Authentication.Default',
56+
'loginUrl' => '/users/login',
57+
]);
58+
59+
Using regex:
60+
61+
.. code-block:: php
62+
63+
$service->loadAuthenticator('Authentication.Form', [
64+
'urlChecker' => [
65+
'className' => 'Authentication.Default',
66+
'useRegex' => true,
67+
],
68+
'loginUrl' => '%^/[a-z]{2}/users/login/?$%',
69+
]);
1670
1771
Options:
1872

1973
- **checkFullUrl**: To compare the full URL, including protocol, host
2074
and port or not. Default is ``false``
2175
- **useRegex**: Compares the URL by a regular expression provided in
22-
the ``$loginUrls`` argument of the checker.
76+
the ``loginUrl`` configuration.
77+
78+
MultiUrlChecker
79+
---------------
80+
81+
Use this checker when you need to support multiple login URLs (e.g., for multi-language sites).
82+
You must explicitly configure this checker - it is not auto-detected.
2383

24-
CakeRouterUrlChecker
25-
--------------------
84+
Multiple string URLs:
2685

27-
Use this checker if you want to use the array notation of CakePHPs
28-
routing system. The checker also works with named routes.
86+
.. code-block:: php
2987
3088
$service->loadAuthenticator('Authentication.Form', [
31-
'urlChecker' => 'Authentication.CakeRouter',
32-
'fields' => [
33-
AbstractIdentifier::CREDENTIAL_USERNAME => 'email',
34-
AbstractIdentifier::CREDENTIAL_PASSWORD => 'password',
89+
'urlChecker' => 'Authentication.Multi',
90+
'loginUrl' => [
91+
'/en/users/login',
92+
'/de/users/login',
3593
],
94+
]);
95+
96+
Multiple CakePHP route arrays:
97+
98+
.. code-block:: php
99+
100+
$service->loadAuthenticator('Authentication.Form', [
101+
'urlChecker' => 'Authentication.Multi',
36102
'loginUrl' => [
37-
'prefix' => false,
38-
'plugin' => false,
39-
'controller' => 'Users',
40-
'action' => 'login',
103+
['lang' => 'en', 'controller' => 'Users', 'action' => 'login'],
104+
['lang' => 'de', 'controller' => 'Users', 'action' => 'login'],
41105
],
42106
]);
43107
44108
Options:
109+
45110
- **checkFullUrl**: To compare the full URL, including protocol, host
46111
and port or not. Default is ``false``
112+
- **useRegex**: Compares URLs by regular expressions. Default is ``false``
47113

48114
Implementing your own Checker
49115
-----------------------------
50116

51-
An URL checker **must** implement the ``UrlCheckerInterface``.
117+
An URL checkers **must** implement the ``UrlCheckerInterface``.

0 commit comments

Comments
 (0)