Skip to content

Commit 58e3de3

Browse files
Doc comment
1 parent 1e029fa commit 58e3de3

File tree

1 file changed

+33
-7
lines changed

1 file changed

+33
-7
lines changed

src/Pinoco/Router.php

Lines changed: 33 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,33 @@
1818
* Pattern matching router.
1919
* This utility can be used on any phase of Pinoco runtime process.
2020
*
21+
* <code>
22+
* $router = Pinoco::instance()->route();
23+
* $router->pass(array('', 'index.html',))
24+
* ->on('list', function() use($self, $data) {
25+
* // ...
26+
* })
27+
* ->on('show/{id}', function($id) use($self, $data) {
28+
* // ...
29+
* })
30+
* ->on('POST:post', function() use($self, $data) {
31+
* // ...
32+
* })
33+
* ->on('GET:post', array($this, 'forbidden'))
34+
* ->on('*', array($this, 'notfound'));
35+
* </code>
36+
*
37+
* Pattern rules:
38+
*
39+
* <pre>
40+
* '/index' : Fixed route.
41+
* 'index' : Fixed route in relative path from current (_enter) hook.
42+
* '/show/{id}' : Parametrized one. Such path elements are passed to handler.
43+
* 'GET: /edit/{id}' or
44+
* 'POST: /edit/{id}' : Different HTTP methods can be different routes.
45+
* '*:*' : Matches any patterns. Useful to be bound to Pinoco::notfound() or forbidden().
46+
* </pre>
47+
*
2148
* @package Pinoco
2249
*/
2350
class Pinoco_Router
@@ -41,12 +68,6 @@ public function __construct($pinoco)
4168
/**
4269
* Routing rules which binds URI path to any callable.
4370
*
44-
* '/index' : Fixed route.
45-
* 'index' : Fixed route in relative path from current hook.
46-
* '/show/{id}' : Parametrized one. Such path elements are passed to handler.
47-
* 'GET: /edit/{id}' or 'POST: /edit/{id}' : Different HTTP methods can be different routes.
48-
* '*:*' : Matches any patterns. Useful to be bound to Pinoco::notfound() or forbidden().
49-
*
5071
* Specified handler is called immediately if the route matches. Please note that
5172
* this method is not a definition but invoker.
5273
*
@@ -84,7 +105,7 @@ public function on($route, $handler)
84105

85106
/**
86107
* Specified route is ignored and delegated to the next script step.
87-
* This method is useful to ignore matching patterns below. (e.g. 'z*:*')
108+
* This method is useful to ignore matching patterns below. (e.g. '*:*')
88109
*
89110
* @param string|array $route
90111
* @return $this
@@ -173,6 +194,11 @@ private function matchesWithPath($path)
173194
}
174195
}
175196

197+
/**
198+
* @param $matches
199+
* @return string
200+
* @internal
201+
*/
176202
public function __each_path_args($matches)
177203
{
178204
$name = $matches[1];

0 commit comments

Comments
 (0)