@@ -81,7 +81,7 @@ discard block |
||
81 | 81 | * OCS routes go into a different collection |
82 | 82 | */ |
83 | 83 | $oldCollection = $this->router->getCurrentCollection(); |
84 | - $this->router->useCollection($oldCollection . '.ocs'); |
|
84 | + $this->router->useCollection($oldCollection.'.ocs'); |
|
85 | 85 | |
86 | 86 | // parse ocs simple routes |
87 | 87 | $this->processOCS($this->routes); |
@@ -97,9 +97,9 @@ discard block |
||
97 | 97 | foreach ($ocsRoutes as $ocsRoute) { |
98 | 98 | $name = $ocsRoute['name']; |
99 | 99 | $postfix = $ocsRoute['postfix'] ?? ''; |
100 | - $root = $ocsRoute['root'] ?? '/apps/' . $this->appName; |
|
100 | + $root = $ocsRoute['root'] ?? '/apps/'.$this->appName; |
|
101 | 101 | |
102 | - $url = $root . $ocsRoute['url']; |
|
102 | + $url = $root.$ocsRoute['url']; |
|
103 | 103 | $verb = strtoupper($ocsRoute['verb'] ?? 'GET'); |
104 | 104 | |
105 | 105 | $split = explode('#', $name, 2); |
@@ -111,7 +111,7 @@ discard block |
||
111 | 111 | $controllerName = $this->buildControllerName($controller); |
112 | 112 | $actionName = $this->buildActionName($action); |
113 | 113 | |
114 | - $routeName = 'ocs.' . $this->appName . '.' . $controller . '.' . $action . $postfix; |
|
114 | + $routeName = 'ocs.'.$this->appName.'.'.$controller.'.'.$action.$postfix; |
|
115 | 115 | |
116 | 116 | // register the route |
117 | 117 | $handler = new RouteActionHandler($this->container, $controllerName, $actionName); |
@@ -122,13 +122,13 @@ discard block |
||
122 | 122 | |
123 | 123 | // optionally register requirements for route. This is used to |
124 | 124 | // tell the route parser how url parameters should be matched |
125 | - if(array_key_exists('requirements', $ocsRoute)) { |
|
125 | + if (array_key_exists('requirements', $ocsRoute)) { |
|
126 | 126 | $router->requirements($ocsRoute['requirements']); |
127 | 127 | } |
128 | 128 | |
129 | 129 | // optionally register defaults for route. This is used to |
130 | 130 | // tell the route parser how url parameters should be default valued |
131 | - if(array_key_exists('defaults', $ocsRoute)) { |
|
131 | + if (array_key_exists('defaults', $ocsRoute)) { |
|
132 | 132 | $router->defaults($ocsRoute['defaults']); |
133 | 133 | } |
134 | 134 | } |
@@ -167,10 +167,10 @@ discard block |
||
167 | 167 | } else if ($controllerName === 'RequesthandlerController') { |
168 | 168 | $controllerName = 'RequestHandlerController'; |
169 | 169 | } |
170 | - $controllerName = App::buildAppNamespace($appName) . '\\Controller\\' . $controllerName; |
|
170 | + $controllerName = App::buildAppNamespace($appName).'\\Controller\\'.$controllerName; |
|
171 | 171 | } |
172 | 172 | |
173 | - $routeName = $appName . '.' . $controller . '.' . $action . $postfix; |
|
173 | + $routeName = $appName.'.'.$controller.'.'.$action.$postfix; |
|
174 | 174 | |
175 | 175 | // register the route |
176 | 176 | $handler = new RouteActionHandler($this->container, $controllerName, $actionName); |
@@ -180,13 +180,13 @@ discard block |
||
180 | 180 | |
181 | 181 | // optionally register requirements for route. This is used to |
182 | 182 | // tell the route parser how url parameters should be matched |
183 | - if(array_key_exists('requirements', $simpleRoute)) { |
|
183 | + if (array_key_exists('requirements', $simpleRoute)) { |
|
184 | 184 | $router->requirements($simpleRoute['requirements']); |
185 | 185 | } |
186 | 186 | |
187 | 187 | // optionally register defaults for route. This is used to |
188 | 188 | // tell the route parser how url parameters should be default valued |
189 | - if(array_key_exists('defaults', $simpleRoute)) { |
|
189 | + if (array_key_exists('defaults', $simpleRoute)) { |
|
190 | 190 | $router->defaults($simpleRoute['defaults']); |
191 | 191 | } |
192 | 192 | } |
@@ -214,11 +214,11 @@ discard block |
||
214 | 214 | |
215 | 215 | $resources = $routes['ocs-resources'] ?? []; |
216 | 216 | foreach ($resources as $resource => $config) { |
217 | - $root = $config['root'] ?? '/apps/' . $this->appName; |
|
217 | + $root = $config['root'] ?? '/apps/'.$this->appName; |
|
218 | 218 | |
219 | 219 | // the url parameter used as id to the resource |
220 | - foreach($actions as $action) { |
|
221 | - $url = $root . $config['url']; |
|
220 | + foreach ($actions as $action) { |
|
221 | + $url = $root.$config['url']; |
|
222 | 222 | $method = $action['name']; |
223 | 223 | $verb = strtoupper($action['verb'] ?? 'GET'); |
224 | 224 | $collectionAction = $action['on-collection'] ?? false; |
@@ -226,7 +226,7 @@ discard block |
||
226 | 226 | $url .= '/{id}'; |
227 | 227 | } |
228 | 228 | if (isset($action['url-postfix'])) { |
229 | - $url .= '/' . $action['url-postfix']; |
|
229 | + $url .= '/'.$action['url-postfix']; |
|
230 | 230 | } |
231 | 231 | |
232 | 232 | $controller = $resource; |
@@ -234,7 +234,7 @@ discard block |
||
234 | 234 | $controllerName = $this->buildControllerName($controller); |
235 | 235 | $actionName = $this->buildActionName($method); |
236 | 236 | |
237 | - $routeName = 'ocs.' . $this->appName . '.' . strtolower($resource) . '.' . strtolower($method); |
|
237 | + $routeName = 'ocs.'.$this->appName.'.'.strtolower($resource).'.'.strtolower($method); |
|
238 | 238 | |
239 | 239 | $this->router->create($routeName, $url)->method($verb)->action( |
240 | 240 | new RouteActionHandler($this->container, $controllerName, $actionName) |
@@ -267,7 +267,7 @@ discard block |
||
267 | 267 | foreach ($resources as $resource => $config) { |
268 | 268 | |
269 | 269 | // the url parameter used as id to the resource |
270 | - foreach($actions as $action) { |
|
270 | + foreach ($actions as $action) { |
|
271 | 271 | $url = $config['url']; |
272 | 272 | $method = $action['name']; |
273 | 273 | $verb = strtoupper($action['verb'] ?? 'GET'); |
@@ -276,7 +276,7 @@ discard block |
||
276 | 276 | $url .= '/{id}'; |
277 | 277 | } |
278 | 278 | if (isset($action['url-postfix'])) { |
279 | - $url .= '/' . $action['url-postfix']; |
|
279 | + $url .= '/'.$action['url-postfix']; |
|
280 | 280 | } |
281 | 281 | |
282 | 282 | $controller = $resource; |
@@ -284,7 +284,7 @@ discard block |
||
284 | 284 | $controllerName = $this->buildControllerName($controller); |
285 | 285 | $actionName = $this->buildActionName($method); |
286 | 286 | |
287 | - $routeName = $this->appName . '.' . strtolower($resource) . '.' . strtolower($method); |
|
287 | + $routeName = $this->appName.'.'.strtolower($resource).'.'.strtolower($method); |
|
288 | 288 | |
289 | 289 | $this->router->create($routeName, $url)->method($verb)->action( |
290 | 290 | new RouteActionHandler($this->container, $controllerName, $actionName) |
@@ -300,7 +300,7 @@ discard block |
||
300 | 300 | */ |
301 | 301 | private function buildControllerName(string $controller): string { |
302 | 302 | if (!isset($this->controllerNameCache[$controller])) { |
303 | - $this->controllerNameCache[$controller] = $this->underScoreToCamelCase(ucfirst($controller)) . 'Controller'; |
|
303 | + $this->controllerNameCache[$controller] = $this->underScoreToCamelCase(ucfirst($controller)).'Controller'; |
|
304 | 304 | } |
305 | 305 | return $this->controllerNameCache[$controller]; |
306 | 306 | } |
@@ -323,7 +323,7 @@ discard block |
||
323 | 323 | $pattern = '/_[a-z]?/'; |
324 | 324 | return preg_replace_callback( |
325 | 325 | $pattern, |
326 | - function ($matches) { |
|
326 | + function($matches) { |
|
327 | 327 | return strtoupper(ltrim($matches[0], '_')); |
328 | 328 | }, |
329 | 329 | $str); |
@@ -57,10 +57,10 @@ discard block |
||
57 | 57 | * the transformed app id, defaults to OCA\ |
58 | 58 | * @return string the starting namespace for the app |
59 | 59 | */ |
60 | - public static function buildAppNamespace(string $appId, string $topNamespace='OCA\\'): string { |
|
60 | + public static function buildAppNamespace(string $appId, string $topNamespace = 'OCA\\'): string { |
|
61 | 61 | // Hit the cache! |
62 | 62 | if (isset(self::$nameSpaceCache[$appId])) { |
63 | - return $topNamespace . self::$nameSpaceCache[$appId]; |
|
63 | + return $topNamespace.self::$nameSpaceCache[$appId]; |
|
64 | 64 | } |
65 | 65 | |
66 | 66 | $appInfo = \OC_App::getAppInfo($appId); |
@@ -71,7 +71,7 @@ discard block |
||
71 | 71 | self::$nameSpaceCache[$appId] = ucfirst($appId); |
72 | 72 | } |
73 | 73 | |
74 | - return $topNamespace . self::$nameSpaceCache[$appId]; |
|
74 | + return $topNamespace.self::$nameSpaceCache[$appId]; |
|
75 | 75 | } |
76 | 76 | |
77 | 77 | |
@@ -95,11 +95,11 @@ discard block |
||
95 | 95 | // first try $controllerName then go for \OCA\AppName\Controller\$controllerName |
96 | 96 | try { |
97 | 97 | $controller = $container->query($controllerName); |
98 | - } catch(QueryException $e) { |
|
98 | + } catch (QueryException $e) { |
|
99 | 99 | if (strpos($controllerName, '\\Controller\\') !== false) { |
100 | 100 | // This is from a global registered app route that is not enabled. |
101 | 101 | [/*OC(A)*/, $app, /* Controller/Name*/] = explode('\\', $controllerName, 3); |
102 | - throw new HintException('App ' . strtolower($app) . ' is not enabled'); |
|
102 | + throw new HintException('App '.strtolower($app).' is not enabled'); |
|
103 | 103 | } |
104 | 104 | |
105 | 105 | if ($appName === 'core') { |
@@ -109,7 +109,7 @@ discard block |
||
109 | 109 | } else { |
110 | 110 | $appNameSpace = self::buildAppNamespace($appName); |
111 | 111 | } |
112 | - $controllerName = $appNameSpace . '\\Controller\\' . $controllerName; |
|
112 | + $controllerName = $appNameSpace.'\\Controller\\'.$controllerName; |
|
113 | 113 | $controller = $container->query($controllerName); |
114 | 114 | } |
115 | 115 | |
@@ -127,17 +127,17 @@ discard block |
||
127 | 127 | |
128 | 128 | $io = $container[IOutput::class]; |
129 | 129 | |
130 | - if(!is_null($httpHeaders)) { |
|
130 | + if (!is_null($httpHeaders)) { |
|
131 | 131 | $io->setHeader($httpHeaders); |
132 | 132 | } |
133 | 133 | |
134 | - foreach($responseHeaders as $name => $value) { |
|
135 | - $io->setHeader($name . ': ' . $value); |
|
134 | + foreach ($responseHeaders as $name => $value) { |
|
135 | + $io->setHeader($name.': '.$value); |
|
136 | 136 | } |
137 | 137 | |
138 | - foreach($responseCookies as $name => $value) { |
|
138 | + foreach ($responseCookies as $name => $value) { |
|
139 | 139 | $expireDate = null; |
140 | - if($value['expireDate'] instanceof \DateTime) { |
|
140 | + if ($value['expireDate'] instanceof \DateTime) { |
|
141 | 141 | $expireDate = $value['expireDate']->getTimestamp(); |
142 | 142 | } |
143 | 143 | $io->setCookie( |
@@ -161,7 +161,7 @@ discard block |
||
161 | 161 | if ($response instanceof ICallbackResponse) { |
162 | 162 | $response->callback($io); |
163 | 163 | } else if (!is_null($output)) { |
164 | - $io->setHeader('Content-Length: ' . strlen($output)); |
|
164 | + $io->setHeader('Content-Length: '.strlen($output)); |
|
165 | 165 | $io->setOutput($output); |
166 | 166 | } |
167 | 167 | } |
@@ -181,14 +181,14 @@ discard block |
||
181 | 181 | * @param DIContainer $container an instance of a pimple container. |
182 | 182 | */ |
183 | 183 | public static function part(string $controllerName, string $methodName, array $urlParams, |
184 | - DIContainer $container){ |
|
184 | + DIContainer $container) { |
|
185 | 185 | |
186 | 186 | $container['urlParams'] = $urlParams; |
187 | 187 | $controller = $container[$controllerName]; |
188 | 188 | |
189 | 189 | $dispatcher = $container['Dispatcher']; |
190 | 190 | |
191 | - list(, , $output) = $dispatcher->dispatch($controller, $methodName); |
|
191 | + list(,, $output) = $dispatcher->dispatch($controller, $methodName); |
|
192 | 192 | return $output; |
193 | 193 | } |
194 | 194 |