1 | <?php |
||
10 | class LaravelGenerator extends AbstractGenerator |
||
11 | { |
||
12 | /** |
||
13 | * @param Route $route |
||
14 | * |
||
15 | * @return mixed |
||
16 | */ |
||
17 | protected function getUri($route) |
||
18 | { |
||
19 | return $route->getUri(); |
||
20 | } |
||
21 | |||
22 | /** |
||
23 | * @param \Illuminate\Routing\Route $route |
||
24 | * @param array $bindings |
||
25 | * @param array $headers |
||
26 | * @param bool $withResponse |
||
27 | * |
||
28 | * @return array |
||
29 | */ |
||
30 | public function processRoute($route, $bindings = [], $headers = [], $withResponse = true) |
||
31 | { |
||
32 | $content = ''; |
||
33 | |||
34 | $routeAction = $route->getAction(); |
||
35 | $routeGroup = $this->getRouteGroup($routeAction['uses']); |
||
36 | $routeDescription = $this->getRouteDescription($routeAction['uses']); |
||
37 | |||
38 | if ($withResponse) { |
||
39 | $response = $this->getRouteResponse($route, $bindings, $headers); |
||
40 | if ($response->headers->get('Content-Type') === 'application/json') { |
||
41 | $content = json_encode(json_decode($response->getContent()), JSON_PRETTY_PRINT); |
||
42 | } else { |
||
43 | $content = $response->getContent(); |
||
44 | } |
||
45 | } |
||
46 | |||
47 | return $this->getParameters([ |
||
48 | 'id' => md5($route->getUri().':'.implode($route->getMethods())), |
||
49 | 'resource' => $routeGroup, |
||
50 | 'title' => $routeDescription['short'], |
||
51 | 'description' => $routeDescription['long'], |
||
52 | 'methods' => $route->getMethods(), |
||
53 | 'uri' => $route->getUri(), |
||
54 | 'parameters' => [], |
||
55 | 'response' => $content, |
||
56 | ], $routeAction, $bindings); |
||
57 | } |
||
58 | |||
59 | /** |
||
60 | * Prepares / Disables route middlewares. |
||
61 | * |
||
62 | * @param bool $disable |
||
63 | * |
||
64 | * @return void |
||
65 | */ |
||
66 | public function prepareMiddleware($disable = true) |
||
70 | |||
71 | /** |
||
72 | * Call the given URI and return the Response. |
||
73 | * |
||
74 | * @param string $method |
||
75 | * @param string $uri |
||
76 | * @param array $parameters |
||
77 | * @param array $cookies |
||
78 | * @param array $files |
||
79 | * @param array $server |
||
80 | * @param string $content |
||
81 | * |
||
82 | * @return \Illuminate\Http\Response |
||
83 | */ |
||
84 | public function callRoute($method, $uri, $parameters = [], $cookies = [], $files = [], $server = [], $content = null) |
||
108 | |||
109 | /** |
||
110 | * @param string $route |
||
111 | * @param array $bindings |
||
112 | * |
||
113 | * @return array |
||
114 | */ |
||
115 | protected function getRouteRules($route, $bindings) |
||
145 | } |
||
146 |
This check marks calls to methods that do not seem to exist on an object.
This is most likely the result of a method being renamed without all references to it being renamed likewise.