1 | <?php namespace App\Services\Routing; |
||
8 | class LocalizedRouter extends Router |
||
9 | { |
||
10 | /** |
||
11 | * Create a new Router instance. |
||
12 | * |
||
13 | * @param \Illuminate\Contracts\Events\Dispatcher $events |
||
14 | * @param \Illuminate\Container\Container $container |
||
15 | */ |
||
16 | 31 | public function __construct(Dispatcher $events, Container $container = null) |
|
17 | { |
||
18 | 31 | parent::__construct($events, $container); |
|
19 | |||
20 | 31 | $this->routes = new LocalizedRouteCollection; |
|
21 | 31 | } |
|
22 | |||
23 | /** |
||
24 | * Add a route to the underlying route collection. |
||
25 | * |
||
26 | * @param array|string $methods |
||
27 | * @param string $uri |
||
28 | * @param \Closure|array|string $action |
||
29 | * |
||
30 | * @return \Illuminate\Routing\Route |
||
31 | */ |
||
32 | 31 | protected function addRoute($methods, $uri, $action) |
|
39 | |||
40 | /** |
||
41 | * Route a controller to a URI with wildcard routing. |
||
42 | * |
||
43 | * @param string $uri |
||
44 | * @param string $controller |
||
45 | * @param array $names |
||
46 | * |
||
47 | * @return void |
||
48 | * |
||
49 | * @deprecated since version 5.2. |
||
50 | */ |
||
51 | public function controller($uri, $controller, $names = []) |
||
52 | { |
||
53 | $prepended = $controller; |
||
54 | |||
55 | // First, we will check to see if a controller prefix has been registered in |
||
56 | // the route group. If it has, we will need to prefix it before trying to |
||
57 | // reflect into the class instance and pull out the method for routing. |
||
58 | if (!empty($this->groupStack)) { |
||
59 | $prepended = $this->prependGroupUses($controller); |
||
60 | } |
||
61 | |||
62 | $controllerInspector = new ControllerInspector; |
||
|
|||
63 | $routable = $controllerInspector->getRoutable($prepended, $uri); |
||
64 | |||
65 | // Now we apply our Localization modifications. |
||
66 | foreach ($routable as &$routes) { |
||
67 | foreach ($routes as &$route) { |
||
68 | $route['plain'] = $this->localizeUris($route['plain']); |
||
69 | unset($route); |
||
70 | } |
||
71 | unset($routes); |
||
72 | } |
||
73 | |||
74 | // When a controller is routed using this method, we use Reflection to parse |
||
75 | // out all of the routable methods for the controller, then register each |
||
76 | // route explicitly for the developers, so reverse routing is possible. |
||
77 | foreach ($routable as $method => $routes) { |
||
78 | foreach ($routes as $route) { |
||
79 | $this->registerInspected($route, $controller, $method, $names); |
||
80 | } |
||
81 | } |
||
82 | |||
83 | $this->addFallthroughRoute($controller, $uri); |
||
84 | } |
||
85 | |||
86 | /** |
||
87 | * Route a resource to a controller. |
||
88 | * |
||
89 | * @param string $name |
||
90 | * @param string $controller |
||
91 | * @param array $options |
||
92 | * |
||
93 | * @return void |
||
94 | */ |
||
95 | 31 | public function resource($name, $controller, array $options = []) |
|
105 | |||
106 | /** |
||
107 | * Add a fallthrough route for a controller. |
||
108 | * |
||
109 | * @param string $controller |
||
110 | * @param string $uri |
||
111 | * |
||
112 | * @return void |
||
113 | * |
||
114 | * @deprecated since version 5.2. |
||
115 | */ |
||
116 | protected function addFallthroughRoute($controller, $uri) |
||
117 | { |
||
118 | $localizedUri = app('translator')->get('routes.' . $uri . '.'); |
||
119 | if (false !== strpos($localizedUri, '.')) { |
||
120 | $localizedUri = $uri; |
||
121 | } |
||
122 | |||
123 | parent::addFallthroughRoute($controller, $localizedUri); |
||
124 | } |
||
125 | |||
126 | /** |
||
127 | * @param string $uri |
||
128 | * |
||
129 | * @return string |
||
130 | */ |
||
131 | 31 | private function localizeUris($uri) |
|
158 | } |
||
159 |
This class, trait or interface has been deprecated. The supplier of the file has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the type will be removed from the class and what other constant to use instead.