1 | <?php |
||
9 | class RouteParser implements Parser |
||
10 | { |
||
11 | /** |
||
12 | * @var UrlParser |
||
13 | */ |
||
14 | private $parser; |
||
15 | |||
16 | /** |
||
17 | * @var Translator |
||
18 | */ |
||
19 | private $translator; |
||
20 | |||
21 | private $name; |
||
22 | private $parameters = []; |
||
23 | private $localeslug; |
||
24 | |||
25 | 50 | public function __construct(UrlParser $parser, Translator $translator) |
|
30 | |||
31 | /** |
||
32 | * Set the routename. |
||
33 | * |
||
34 | * @param $name |
||
35 | * |
||
36 | * @return mixed |
||
37 | */ |
||
38 | 33 | public function set($name) |
|
44 | |||
45 | /** |
||
46 | * Retrieve the generated / altered url |
||
47 | * If no translated routekey is found, it means the route itself does not need to be |
||
48 | * translated and we allow the native url generator to deal with the route generation. |
||
49 | * |
||
50 | * @return mixed |
||
51 | */ |
||
52 | 33 | public function get() |
|
62 | |||
63 | /** |
||
64 | * Place locale segment in front of url path |
||
65 | * e.g. /foo/bar is transformed into /en/foo/bar. |
||
66 | * |
||
67 | * @param null $localeslug |
||
68 | * |
||
69 | * @return string |
||
70 | */ |
||
71 | 32 | public function localize($localeslug = null) |
|
78 | |||
79 | /** |
||
80 | * @param array $parameters |
||
81 | * |
||
82 | * @return $this |
||
83 | */ |
||
84 | 32 | public function parameters(array $parameters = []) |
|
90 | |||
91 | /** |
||
92 | * @param bool $secure |
||
93 | * |
||
94 | * @return $this |
||
95 | */ |
||
96 | 1 | public function secure($secure = true) |
|
102 | |||
103 | /** |
||
104 | * Replace route parameters. |
||
105 | * |
||
106 | * @param $uri |
||
107 | * @param array $parameters |
||
108 | * |
||
109 | * @return mixed|string |
||
110 | */ |
||
111 | 6 | protected function replaceParameters($uri, $parameters = []) |
|
120 | |||
121 | /** |
||
122 | * Replace all of the wildcard parameters for a route path. |
||
123 | * |
||
124 | * @note: based on the Illuminate\Routing\UrlGenerator code |
||
125 | * |
||
126 | * @param string $path |
||
127 | * @param array $parameters |
||
128 | * |
||
129 | * @return string |
||
130 | */ |
||
131 | 6 | protected function replaceRouteParameters($path, array $parameters) |
|
143 | |||
144 | /** |
||
145 | * Replace all of the named parameters in the path. |
||
146 | * |
||
147 | * @note: based on the Illuminate\Routing\UrlGenerator code |
||
148 | * |
||
149 | * @param string $path |
||
150 | * @param array $parameters |
||
151 | * |
||
152 | * @return string |
||
153 | */ |
||
154 | protected function replaceNamedParameters($path, &$parameters) |
||
160 | } |
||
161 |