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 | 141 | public function __construct(UrlParser $parser,Translator $translator) |
|
30 | |||
31 | /** |
||
32 | * Set the routename |
||
33 | * |
||
34 | * @param $name |
||
35 | * @return mixed |
||
36 | */ |
||
37 | 90 | public function set($name) |
|
43 | |||
44 | /** |
||
45 | * Retrieve the generated / altered url |
||
46 | * If no translated routekey is found, it means the route itself does not need to be |
||
47 | * translated and we allow the native url generator to deal with the route generation |
||
48 | * |
||
49 | * @return mixed |
||
50 | */ |
||
51 | 90 | public function get() |
|
61 | |||
62 | /** |
||
63 | * Place locale segment in front of url path |
||
64 | * e.g. /foo/bar is transformed into /en/foo/bar |
||
65 | * |
||
66 | * @param null $localeslug |
||
67 | * @return string |
||
68 | */ |
||
69 | 87 | public function localize($localeslug = null) |
|
76 | |||
77 | /** |
||
78 | * @param array $parameters |
||
79 | * @return $this |
||
80 | */ |
||
81 | 90 | public function parameters(array $parameters = []) |
|
87 | |||
88 | /** |
||
89 | * @param bool $secure |
||
90 | * @return $this |
||
91 | */ |
||
92 | 3 | public function secure($secure = true) |
|
98 | |||
99 | /** |
||
100 | * Replace route parameters |
||
101 | * |
||
102 | * @param $uri |
||
103 | * @param array $parameters |
||
104 | * @return mixed|string |
||
105 | */ |
||
106 | 12 | protected function replaceParameters($uri, $parameters = []) |
|
115 | |||
116 | /** |
||
117 | * Replace all of the wildcard parameters for a route path. |
||
118 | * @note: based on the Illuminate\Routing\UrlGenerator code |
||
119 | * |
||
120 | * @param string $path |
||
121 | * @param array $parameters |
||
122 | * @return string |
||
123 | */ |
||
124 | 12 | protected function replaceRouteParameters($path, array $parameters) |
|
136 | |||
137 | /** |
||
138 | * Replace all of the named parameters in the path. |
||
139 | * @note: based on the Illuminate\Routing\UrlGenerator code |
||
140 | * |
||
141 | * @param string $path |
||
142 | * @param array $parameters |
||
143 | * @return string |
||
144 | */ |
||
145 | protected function replaceNamedParameters($path, &$parameters) |
||
151 | } |