22
33include_once __DIR__ . '/../vendor/autoload.php ' ;
44
5- $ router = new \Deimos \Router \Router ();
6-
7- $ router ->setMethod ('GET ' );
8-
9-
10- //$route = new \Deimos\Route\Route(
11- // ['(/<lang:[a-z]{2}>)/<controller>(/<action>(/<id:\d+>))'],
12- // [
13- // 'lang' => 'ru',
14- // 'action' => 'default'
15- // ]
16- //);
17- //$router->addRoute($route); // OR
18-
19- $ router ->setRoutes ([
20- [
21- 'type ' => 'pattern ' ,
22- 'path ' => [
23- '(/<lang:[a-z]{2}>)/<controller>(/<action>(/<id:\d+>)) ' ,
24- [
25- 'controller ' => '[\w-<>!12]+ '
26- ]
27- ],
28-
29- 'defaults ' => [
30- // 'lang' => 'ru',
31- 'action ' => 'default '
32- ]
33- ],
34- [
35- 'type ' => 'prefix ' ,
36- 'path ' => '/get/ ' ,
37-
38- 'resolver ' => [
39- [
40- 'type ' => 'pattern ' ,
41- 'path ' => 'image/<hash:[a-z0-9]+/[a-z0-9]+>/<frame:\d+><ext:\.(png|jpe?g)> ' ,
42-
43- 'methods ' => [
44- 'GET '
45- ],
46-
47- 'defaults ' => [
48- 'action ' => 'image ' ,
49- ]
50- ],
51- [
52- 'type ' => 'pattern ' ,
53- 'path ' => 'file/<size>/<path:.*> ' ,
54-
55- 'defaults ' => [
56- 'action ' => 'file ' ,
57- ]
58- ],
59- ],
60-
61- 'defaults ' => [
62- 'controller ' => 'file ' ,
63- 'runner ' => 'pub ' ,
64- 'notFound ' => 'default '
65- ]
66- ]
67- ]);
68-
69- var_dump ($ route = $ router ->getCurrentRoute ('/get/image/ab/cd/0.png ' ), $ route ->attributes ());
70- var_dump ($ route = $ router ->getCurrentRoute ('/hello-world ' ), $ route ->attributes ());
71- var_dump ($ route = $ router ->getCurrentRoute ('/en/hello-world ' ), $ route ->attributes ());
72- die;
5+ $ builder = new Deimos \Builder \Builder ();
6+ $ helper = new \Deimos \Helper \Helper ($ builder );
7+ $ config = new \Deimos \Config \Config ($ helper , __DIR__ );
8+
9+ $ slice = $ config ->get ('global ' );
10+
11+ $ cache = new \Deimos \CacheHelper \SliceHelper (__DIR__ . '/cache ' );
12+ $ router = new \Deimos \Router \Router ($ slice , $ cache );
13+
14+ $ route = $ router ->getCurrentRoute ();
15+
16+ var_dump (
17+ \Deimos \Router \route ($ route ),
18+ $ route ->getAttributes (),
19+ $ route ->getDefaults (),
20+ $ route ->getHttp (),
21+ $ route ->getPath (),
22+ $ route ->getRegex (),
23+ $ route ->getRegexPath ()
24+ );
0 commit comments