Completed
Pull Request — master (#5818)
by Morris
13:27
created
lib/private/Route/Router.php 2 patches
Indentation   +302 added lines, -302 removed lines patch added patch discarded remove patch
@@ -45,332 +45,332 @@
 block discarded – undo
45 45
 use Symfony\Component\Routing\Exception\ResourceNotFoundException;
46 46
 
47 47
 class Router implements IRouter {
48
-	/** @var RouteCollection[] */
49
-	protected $collections = [];
50
-	/** @var null|RouteCollection */
51
-	protected $collection = null;
52
-	/** @var null|string */
53
-	protected $collectionName = null;
54
-	/** @var null|RouteCollection */
55
-	protected $root = null;
56
-	/** @var null|UrlGenerator */
57
-	protected $generator = null;
58
-	/** @var string[] */
59
-	protected $routingFiles;
60
-	/** @var bool */
61
-	protected $loaded = false;
62
-	/** @var array */
63
-	protected $loadedApps = [];
64
-	/** @var ILogger */
65
-	protected $logger;
66
-	/** @var RequestContext */
67
-	protected $context;
48
+    /** @var RouteCollection[] */
49
+    protected $collections = [];
50
+    /** @var null|RouteCollection */
51
+    protected $collection = null;
52
+    /** @var null|string */
53
+    protected $collectionName = null;
54
+    /** @var null|RouteCollection */
55
+    protected $root = null;
56
+    /** @var null|UrlGenerator */
57
+    protected $generator = null;
58
+    /** @var string[] */
59
+    protected $routingFiles;
60
+    /** @var bool */
61
+    protected $loaded = false;
62
+    /** @var array */
63
+    protected $loadedApps = [];
64
+    /** @var ILogger */
65
+    protected $logger;
66
+    /** @var RequestContext */
67
+    protected $context;
68 68
 
69
-	/**
70
-	 * @param ILogger $logger
71
-	 */
72
-	public function __construct(ILogger $logger) {
73
-		$this->logger = $logger;
74
-		$baseUrl = \OC::$WEBROOT;
75
-		if(!(\OC::$server->getConfig()->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) {
76
-			$baseUrl = \OC::$server->getURLGenerator()->linkTo('', 'index.php');
77
-		}
78
-		if (!\OC::$CLI && isset($_SERVER['REQUEST_METHOD'])) {
79
-			$method = $_SERVER['REQUEST_METHOD'];
80
-		} else {
81
-			$method = 'GET';
82
-		}
83
-		$request = \OC::$server->getRequest();
84
-		$host = $request->getServerHost();
85
-		$schema = $request->getServerProtocol();
86
-		$this->context = new RequestContext($baseUrl, $method, $host, $schema);
87
-		// TODO cache
88
-		$this->root = $this->getCollection('root');
89
-	}
69
+    /**
70
+     * @param ILogger $logger
71
+     */
72
+    public function __construct(ILogger $logger) {
73
+        $this->logger = $logger;
74
+        $baseUrl = \OC::$WEBROOT;
75
+        if(!(\OC::$server->getConfig()->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) {
76
+            $baseUrl = \OC::$server->getURLGenerator()->linkTo('', 'index.php');
77
+        }
78
+        if (!\OC::$CLI && isset($_SERVER['REQUEST_METHOD'])) {
79
+            $method = $_SERVER['REQUEST_METHOD'];
80
+        } else {
81
+            $method = 'GET';
82
+        }
83
+        $request = \OC::$server->getRequest();
84
+        $host = $request->getServerHost();
85
+        $schema = $request->getServerProtocol();
86
+        $this->context = new RequestContext($baseUrl, $method, $host, $schema);
87
+        // TODO cache
88
+        $this->root = $this->getCollection('root');
89
+    }
90 90
 
91
-	/**
92
-	 * Get the files to load the routes from
93
-	 *
94
-	 * @return string[]
95
-	 */
96
-	public function getRoutingFiles() {
97
-		if (!isset($this->routingFiles)) {
98
-			$this->routingFiles = [];
99
-			foreach (\OC_APP::getEnabledApps() as $app) {
100
-				$appPath = \OC_App::getAppPath($app);
101
-				if($appPath !== false) {
102
-					$file = $appPath . '/appinfo/routes.php';
103
-					if (file_exists($file)) {
104
-						$this->routingFiles[$app] = $file;
105
-					}
106
-				}
107
-			}
108
-		}
109
-		return $this->routingFiles;
110
-	}
91
+    /**
92
+     * Get the files to load the routes from
93
+     *
94
+     * @return string[]
95
+     */
96
+    public function getRoutingFiles() {
97
+        if (!isset($this->routingFiles)) {
98
+            $this->routingFiles = [];
99
+            foreach (\OC_APP::getEnabledApps() as $app) {
100
+                $appPath = \OC_App::getAppPath($app);
101
+                if($appPath !== false) {
102
+                    $file = $appPath . '/appinfo/routes.php';
103
+                    if (file_exists($file)) {
104
+                        $this->routingFiles[$app] = $file;
105
+                    }
106
+                }
107
+            }
108
+        }
109
+        return $this->routingFiles;
110
+    }
111 111
 
112
-	/**
113
-	 * Loads the routes
114
-	 *
115
-	 * @param null|string $app
116
-	 */
117
-	public function loadRoutes($app = null) {
118
-		if(is_string($app)) {
119
-			$app = \OC_App::cleanAppId($app);
120
-		}
112
+    /**
113
+     * Loads the routes
114
+     *
115
+     * @param null|string $app
116
+     */
117
+    public function loadRoutes($app = null) {
118
+        if(is_string($app)) {
119
+            $app = \OC_App::cleanAppId($app);
120
+        }
121 121
 
122
-		$requestedApp = $app;
123
-		if ($this->loaded) {
124
-			return;
125
-		}
126
-		if (is_null($app)) {
127
-			$this->loaded = true;
128
-			$routingFiles = $this->getRoutingFiles();
129
-		} else {
130
-			if (isset($this->loadedApps[$app])) {
131
-				return;
132
-			}
133
-			$file = \OC_App::getAppPath($app) . '/appinfo/routes.php';
134
-			if ($file !== false && file_exists($file)) {
135
-				$routingFiles = [$app => $file];
136
-			} else {
137
-				$routingFiles = [];
138
-			}
139
-		}
140
-		\OC::$server->getEventLogger()->start('loadroutes' . $requestedApp, 'Loading Routes');
141
-		foreach ($routingFiles as $app => $file) {
142
-			if (!isset($this->loadedApps[$app])) {
143
-				if (!\OC_App::isAppLoaded($app)) {
144
-					// app MUST be loaded before app routes
145
-					// try again next time loadRoutes() is called
146
-					$this->loaded = false;
147
-					continue;
148
-				}
149
-				$this->loadedApps[$app] = true;
150
-				$this->useCollection($app);
151
-				$this->requireRouteFile($file, $app);
152
-				$collection = $this->getCollection($app);
153
-				$collection->addPrefix('/apps/' . $app);
154
-				$this->root->addCollection($collection);
122
+        $requestedApp = $app;
123
+        if ($this->loaded) {
124
+            return;
125
+        }
126
+        if (is_null($app)) {
127
+            $this->loaded = true;
128
+            $routingFiles = $this->getRoutingFiles();
129
+        } else {
130
+            if (isset($this->loadedApps[$app])) {
131
+                return;
132
+            }
133
+            $file = \OC_App::getAppPath($app) . '/appinfo/routes.php';
134
+            if ($file !== false && file_exists($file)) {
135
+                $routingFiles = [$app => $file];
136
+            } else {
137
+                $routingFiles = [];
138
+            }
139
+        }
140
+        \OC::$server->getEventLogger()->start('loadroutes' . $requestedApp, 'Loading Routes');
141
+        foreach ($routingFiles as $app => $file) {
142
+            if (!isset($this->loadedApps[$app])) {
143
+                if (!\OC_App::isAppLoaded($app)) {
144
+                    // app MUST be loaded before app routes
145
+                    // try again next time loadRoutes() is called
146
+                    $this->loaded = false;
147
+                    continue;
148
+                }
149
+                $this->loadedApps[$app] = true;
150
+                $this->useCollection($app);
151
+                $this->requireRouteFile($file, $app);
152
+                $collection = $this->getCollection($app);
153
+                $collection->addPrefix('/apps/' . $app);
154
+                $this->root->addCollection($collection);
155 155
 
156
-				// Also add the OCS collection
157
-				$collection = $this->getCollection($app.'.ocs');
158
-				$collection->addPrefix('/ocsapp');
159
-				$this->root->addCollection($collection);
160
-			}
161
-		}
162
-		if (!isset($this->loadedApps['core'])) {
163
-			$this->loadedApps['core'] = true;
164
-			$this->useCollection('root');
165
-			require_once __DIR__ . '/../../../settings/routes.php';
166
-			require_once __DIR__ . '/../../../core/routes.php';
156
+                // Also add the OCS collection
157
+                $collection = $this->getCollection($app.'.ocs');
158
+                $collection->addPrefix('/ocsapp');
159
+                $this->root->addCollection($collection);
160
+            }
161
+        }
162
+        if (!isset($this->loadedApps['core'])) {
163
+            $this->loadedApps['core'] = true;
164
+            $this->useCollection('root');
165
+            require_once __DIR__ . '/../../../settings/routes.php';
166
+            require_once __DIR__ . '/../../../core/routes.php';
167 167
 
168
-			// Also add the OCS collection
169
-			$collection = $this->getCollection('root.ocs');
170
-			$collection->addPrefix('/ocsapp');
171
-			$this->root->addCollection($collection);
172
-		}
173
-		\OC::$server->getEventLogger()->end('loadroutes' . $requestedApp);
174
-	}
168
+            // Also add the OCS collection
169
+            $collection = $this->getCollection('root.ocs');
170
+            $collection->addPrefix('/ocsapp');
171
+            $this->root->addCollection($collection);
172
+        }
173
+        \OC::$server->getEventLogger()->end('loadroutes' . $requestedApp);
174
+    }
175 175
 
176
-	/**
177
-	 * @return string
178
-	 * @deprecated
179
-	 */
180
-	public function getCacheKey() {
181
-		return '';
182
-	}
176
+    /**
177
+     * @return string
178
+     * @deprecated
179
+     */
180
+    public function getCacheKey() {
181
+        return '';
182
+    }
183 183
 
184
-	/**
185
-	 * @param string $name
186
-	 * @return \Symfony\Component\Routing\RouteCollection
187
-	 */
188
-	protected function getCollection($name) {
189
-		if (!isset($this->collections[$name])) {
190
-			$this->collections[$name] = new RouteCollection();
191
-		}
192
-		return $this->collections[$name];
193
-	}
184
+    /**
185
+     * @param string $name
186
+     * @return \Symfony\Component\Routing\RouteCollection
187
+     */
188
+    protected function getCollection($name) {
189
+        if (!isset($this->collections[$name])) {
190
+            $this->collections[$name] = new RouteCollection();
191
+        }
192
+        return $this->collections[$name];
193
+    }
194 194
 
195
-	/**
196
-	 * Sets the collection to use for adding routes
197
-	 *
198
-	 * @param string $name Name of the collection to use.
199
-	 * @return void
200
-	 */
201
-	public function useCollection($name) {
202
-		$this->collection = $this->getCollection($name);
203
-		$this->collectionName = $name;
204
-	}
195
+    /**
196
+     * Sets the collection to use for adding routes
197
+     *
198
+     * @param string $name Name of the collection to use.
199
+     * @return void
200
+     */
201
+    public function useCollection($name) {
202
+        $this->collection = $this->getCollection($name);
203
+        $this->collectionName = $name;
204
+    }
205 205
 
206
-	/**
207
-	 * returns the current collection name in use for adding routes
208
-	 *
209
-	 * @return string the collection name
210
-	 */
211
-	public function getCurrentCollection() {
212
-		return $this->collectionName;
213
-	}
206
+    /**
207
+     * returns the current collection name in use for adding routes
208
+     *
209
+     * @return string the collection name
210
+     */
211
+    public function getCurrentCollection() {
212
+        return $this->collectionName;
213
+    }
214 214
 
215 215
 
216
-	/**
217
-	 * Create a \OC\Route\Route.
218
-	 *
219
-	 * @param string $name Name of the route to create.
220
-	 * @param string $pattern The pattern to match
221
-	 * @param array $defaults An array of default parameter values
222
-	 * @param array $requirements An array of requirements for parameters (regexes)
223
-	 * @return \OC\Route\Route
224
-	 */
225
-	public function create($name,
226
-						   $pattern,
227
-						   array $defaults = [],
228
-						   array $requirements = []) {
229
-		$route = new Route($pattern, $defaults, $requirements);
230
-		$this->collection->add($name, $route);
231
-		return $route;
232
-	}
216
+    /**
217
+     * Create a \OC\Route\Route.
218
+     *
219
+     * @param string $name Name of the route to create.
220
+     * @param string $pattern The pattern to match
221
+     * @param array $defaults An array of default parameter values
222
+     * @param array $requirements An array of requirements for parameters (regexes)
223
+     * @return \OC\Route\Route
224
+     */
225
+    public function create($name,
226
+                            $pattern,
227
+                            array $defaults = [],
228
+                            array $requirements = []) {
229
+        $route = new Route($pattern, $defaults, $requirements);
230
+        $this->collection->add($name, $route);
231
+        return $route;
232
+    }
233 233
 
234
-	/**
235
-	 * Find the route matching $url
236
-	 *
237
-	 * @param string $url The url to find
238
-	 * @throws \Exception
239
-	 * @return void
240
-	 */
241
-	public function match($url) {
242
-		if (substr($url, 0, 6) === '/apps/') {
243
-			// empty string / 'apps' / $app / rest of the route
244
-			list(, , $app,) = explode('/', $url, 4);
234
+    /**
235
+     * Find the route matching $url
236
+     *
237
+     * @param string $url The url to find
238
+     * @throws \Exception
239
+     * @return void
240
+     */
241
+    public function match($url) {
242
+        if (substr($url, 0, 6) === '/apps/') {
243
+            // empty string / 'apps' / $app / rest of the route
244
+            list(, , $app,) = explode('/', $url, 4);
245 245
 
246
-			$app = \OC_App::cleanAppId($app);
247
-			\OC::$REQUESTEDAPP = $app;
248
-			$this->loadRoutes($app);
249
-		} else if (substr($url, 0, 13) === '/ocsapp/apps/') {
250
-			// empty string / 'ocsapp' / 'apps' / $app / rest of the route
251
-			list(, , , $app,) = explode('/', $url, 5);
246
+            $app = \OC_App::cleanAppId($app);
247
+            \OC::$REQUESTEDAPP = $app;
248
+            $this->loadRoutes($app);
249
+        } else if (substr($url, 0, 13) === '/ocsapp/apps/') {
250
+            // empty string / 'ocsapp' / 'apps' / $app / rest of the route
251
+            list(, , , $app,) = explode('/', $url, 5);
252 252
 
253
-			$app = \OC_App::cleanAppId($app);
254
-			\OC::$REQUESTEDAPP = $app;
255
-			$this->loadRoutes($app);
256
-		} else if (substr($url, 0, 6) === '/core/' or substr($url, 0, 10) === '/settings/') {
257
-			\OC::$REQUESTEDAPP = $url;
258
-			if (!\OC::$server->getConfig()->getSystemValue('maintenance', false) && !Util::needUpgrade()) {
259
-				\OC_App::loadApps();
260
-			}
261
-			$this->loadRoutes('core');
262
-		} else {
263
-			$this->loadRoutes();
264
-		}
253
+            $app = \OC_App::cleanAppId($app);
254
+            \OC::$REQUESTEDAPP = $app;
255
+            $this->loadRoutes($app);
256
+        } else if (substr($url, 0, 6) === '/core/' or substr($url, 0, 10) === '/settings/') {
257
+            \OC::$REQUESTEDAPP = $url;
258
+            if (!\OC::$server->getConfig()->getSystemValue('maintenance', false) && !Util::needUpgrade()) {
259
+                \OC_App::loadApps();
260
+            }
261
+            $this->loadRoutes('core');
262
+        } else {
263
+            $this->loadRoutes();
264
+        }
265 265
 
266
-		$matcher = new UrlMatcher($this->root, $this->context);
267
-		try {
268
-			$parameters = $matcher->match($url);
269
-		} catch (ResourceNotFoundException $e) {
270
-			if (substr($url, -1) !== '/') {
271
-				// We allow links to apps/files? for backwards compatibility reasons
272
-				// However, since Symfony does not allow empty route names, the route
273
-				// we need to match is '/', so we need to append the '/' here.
274
-				try {
275
-					$parameters = $matcher->match($url . '/');
276
-				} catch (ResourceNotFoundException $newException) {
277
-					// If we still didn't match a route, we throw the original exception
278
-					throw $e;
279
-				}
280
-			} else {
281
-				throw $e;
282
-			}
283
-		}
266
+        $matcher = new UrlMatcher($this->root, $this->context);
267
+        try {
268
+            $parameters = $matcher->match($url);
269
+        } catch (ResourceNotFoundException $e) {
270
+            if (substr($url, -1) !== '/') {
271
+                // We allow links to apps/files? for backwards compatibility reasons
272
+                // However, since Symfony does not allow empty route names, the route
273
+                // we need to match is '/', so we need to append the '/' here.
274
+                try {
275
+                    $parameters = $matcher->match($url . '/');
276
+                } catch (ResourceNotFoundException $newException) {
277
+                    // If we still didn't match a route, we throw the original exception
278
+                    throw $e;
279
+                }
280
+            } else {
281
+                throw $e;
282
+            }
283
+        }
284 284
 
285
-		\OC::$server->getEventLogger()->start('run_route', 'Run route');
286
-		if (isset($parameters['action'])) {
287
-			$action = $parameters['action'];
288
-			if (!is_callable($action)) {
289
-				throw new \Exception('not a callable action');
290
-			}
291
-			unset($parameters['action']);
292
-			call_user_func($action, $parameters);
293
-		} elseif (isset($parameters['file'])) {
294
-			include $parameters['file'];
295
-		} else {
296
-			throw new \Exception('no action available');
297
-		}
298
-		\OC::$server->getEventLogger()->end('run_route');
299
-	}
285
+        \OC::$server->getEventLogger()->start('run_route', 'Run route');
286
+        if (isset($parameters['action'])) {
287
+            $action = $parameters['action'];
288
+            if (!is_callable($action)) {
289
+                throw new \Exception('not a callable action');
290
+            }
291
+            unset($parameters['action']);
292
+            call_user_func($action, $parameters);
293
+        } elseif (isset($parameters['file'])) {
294
+            include $parameters['file'];
295
+        } else {
296
+            throw new \Exception('no action available');
297
+        }
298
+        \OC::$server->getEventLogger()->end('run_route');
299
+    }
300 300
 
301
-	/**
302
-	 * Get the url generator
303
-	 *
304
-	 * @return \Symfony\Component\Routing\Generator\UrlGenerator
305
-	 *
306
-	 */
307
-	public function getGenerator() {
308
-		if (null !== $this->generator) {
309
-			return $this->generator;
310
-		}
301
+    /**
302
+     * Get the url generator
303
+     *
304
+     * @return \Symfony\Component\Routing\Generator\UrlGenerator
305
+     *
306
+     */
307
+    public function getGenerator() {
308
+        if (null !== $this->generator) {
309
+            return $this->generator;
310
+        }
311 311
 
312
-		return $this->generator = new UrlGenerator($this->root, $this->context);
313
-	}
312
+        return $this->generator = new UrlGenerator($this->root, $this->context);
313
+    }
314 314
 
315
-	/**
316
-	 * Generate url based on $name and $parameters
317
-	 *
318
-	 * @param string $name Name of the route to use.
319
-	 * @param array $parameters Parameters for the route
320
-	 * @param bool $absolute
321
-	 * @return string
322
-	 */
323
-	public function generate($name,
324
-							 $parameters = [],
325
-							 $absolute = false) {
326
-		$this->loadRoutes();
327
-		try {
328
-			$referenceType = UrlGenerator::ABSOLUTE_URL;
329
-			if ($absolute === false) {
330
-				$referenceType = UrlGenerator::ABSOLUTE_PATH;
331
-			}
332
-			return $this->getGenerator()->generate($name, $parameters, $referenceType);
333
-		} catch (RouteNotFoundException $e) {
334
-			$this->logger->logException($e);
335
-			return '';
336
-		}
337
-	}
315
+    /**
316
+     * Generate url based on $name and $parameters
317
+     *
318
+     * @param string $name Name of the route to use.
319
+     * @param array $parameters Parameters for the route
320
+     * @param bool $absolute
321
+     * @return string
322
+     */
323
+    public function generate($name,
324
+                                $parameters = [],
325
+                                $absolute = false) {
326
+        $this->loadRoutes();
327
+        try {
328
+            $referenceType = UrlGenerator::ABSOLUTE_URL;
329
+            if ($absolute === false) {
330
+                $referenceType = UrlGenerator::ABSOLUTE_PATH;
331
+            }
332
+            return $this->getGenerator()->generate($name, $parameters, $referenceType);
333
+        } catch (RouteNotFoundException $e) {
334
+            $this->logger->logException($e);
335
+            return '';
336
+        }
337
+    }
338 338
 
339
-	/**
340
-	 * To isolate the variable scope used inside the $file it is required in it's own method
341
-	 *
342
-	 * @param string $file the route file location to include
343
-	 * @param string $appName
344
-	 */
345
-	private function requireRouteFile($file, $appName) {
346
-		$this->setupRoutes(include_once $file, $appName);
347
-	}
339
+    /**
340
+     * To isolate the variable scope used inside the $file it is required in it's own method
341
+     *
342
+     * @param string $file the route file location to include
343
+     * @param string $appName
344
+     */
345
+    private function requireRouteFile($file, $appName) {
346
+        $this->setupRoutes(include_once $file, $appName);
347
+    }
348 348
 
349 349
 
350
-	/**
351
-	 * If a routes.php file returns an array, try to set up the application and
352
-	 * register the routes for the app. The application class will be chosen by
353
-	 * camelcasing the appname, e.g.: my_app will be turned into
354
-	 * \OCA\MyApp\AppInfo\Application. If that class does not exist, a default
355
-	 * App will be intialized. This makes it optional to ship an
356
-	 * appinfo/application.php by using the built in query resolver
357
-	 *
358
-	 * @param array $routes the application routes
359
-	 * @param string $appName the name of the app.
360
-	 */
361
-	private function setupRoutes($routes, $appName) {
362
-		if (is_array($routes)) {
363
-			$appNameSpace = App::buildAppNamespace($appName);
350
+    /**
351
+     * If a routes.php file returns an array, try to set up the application and
352
+     * register the routes for the app. The application class will be chosen by
353
+     * camelcasing the appname, e.g.: my_app will be turned into
354
+     * \OCA\MyApp\AppInfo\Application. If that class does not exist, a default
355
+     * App will be intialized. This makes it optional to ship an
356
+     * appinfo/application.php by using the built in query resolver
357
+     *
358
+     * @param array $routes the application routes
359
+     * @param string $appName the name of the app.
360
+     */
361
+    private function setupRoutes($routes, $appName) {
362
+        if (is_array($routes)) {
363
+            $appNameSpace = App::buildAppNamespace($appName);
364 364
 
365
-			$applicationClassName = $appNameSpace . '\\AppInfo\\Application';
365
+            $applicationClassName = $appNameSpace . '\\AppInfo\\Application';
366 366
 
367
-			if (class_exists($applicationClassName)) {
368
-				$application = new $applicationClassName();
369
-			} else {
370
-				$application = new App($appName);
371
-			}
367
+            if (class_exists($applicationClassName)) {
368
+                $application = new $applicationClassName();
369
+            } else {
370
+                $application = new App($appName);
371
+            }
372 372
 
373
-			$application->registerRoutes($this, $routes);
374
-		}
375
-	}
373
+            $application->registerRoutes($this, $routes);
374
+        }
375
+    }
376 376
 }
Please login to merge, or discard this patch.
Spacing   +14 added lines, -14 removed lines patch added patch discarded remove patch
@@ -72,7 +72,7 @@  discard block
 block discarded – undo
72 72
 	public function __construct(ILogger $logger) {
73 73
 		$this->logger = $logger;
74 74
 		$baseUrl = \OC::$WEBROOT;
75
-		if(!(\OC::$server->getConfig()->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) {
75
+		if (!(\OC::$server->getConfig()->getSystemValue('htaccess.IgnoreFrontController', false) === true || getenv('front_controller_active') === 'true')) {
76 76
 			$baseUrl = \OC::$server->getURLGenerator()->linkTo('', 'index.php');
77 77
 		}
78 78
 		if (!\OC::$CLI && isset($_SERVER['REQUEST_METHOD'])) {
@@ -98,8 +98,8 @@  discard block
 block discarded – undo
98 98
 			$this->routingFiles = [];
99 99
 			foreach (\OC_APP::getEnabledApps() as $app) {
100 100
 				$appPath = \OC_App::getAppPath($app);
101
-				if($appPath !== false) {
102
-					$file = $appPath . '/appinfo/routes.php';
101
+				if ($appPath !== false) {
102
+					$file = $appPath.'/appinfo/routes.php';
103 103
 					if (file_exists($file)) {
104 104
 						$this->routingFiles[$app] = $file;
105 105
 					}
@@ -115,7 +115,7 @@  discard block
 block discarded – undo
115 115
 	 * @param null|string $app
116 116
 	 */
117 117
 	public function loadRoutes($app = null) {
118
-		if(is_string($app)) {
118
+		if (is_string($app)) {
119 119
 			$app = \OC_App::cleanAppId($app);
120 120
 		}
121 121
 
@@ -130,14 +130,14 @@  discard block
 block discarded – undo
130 130
 			if (isset($this->loadedApps[$app])) {
131 131
 				return;
132 132
 			}
133
-			$file = \OC_App::getAppPath($app) . '/appinfo/routes.php';
133
+			$file = \OC_App::getAppPath($app).'/appinfo/routes.php';
134 134
 			if ($file !== false && file_exists($file)) {
135 135
 				$routingFiles = [$app => $file];
136 136
 			} else {
137 137
 				$routingFiles = [];
138 138
 			}
139 139
 		}
140
-		\OC::$server->getEventLogger()->start('loadroutes' . $requestedApp, 'Loading Routes');
140
+		\OC::$server->getEventLogger()->start('loadroutes'.$requestedApp, 'Loading Routes');
141 141
 		foreach ($routingFiles as $app => $file) {
142 142
 			if (!isset($this->loadedApps[$app])) {
143 143
 				if (!\OC_App::isAppLoaded($app)) {
@@ -150,7 +150,7 @@  discard block
 block discarded – undo
150 150
 				$this->useCollection($app);
151 151
 				$this->requireRouteFile($file, $app);
152 152
 				$collection = $this->getCollection($app);
153
-				$collection->addPrefix('/apps/' . $app);
153
+				$collection->addPrefix('/apps/'.$app);
154 154
 				$this->root->addCollection($collection);
155 155
 
156 156
 				// Also add the OCS collection
@@ -162,15 +162,15 @@  discard block
 block discarded – undo
162 162
 		if (!isset($this->loadedApps['core'])) {
163 163
 			$this->loadedApps['core'] = true;
164 164
 			$this->useCollection('root');
165
-			require_once __DIR__ . '/../../../settings/routes.php';
166
-			require_once __DIR__ . '/../../../core/routes.php';
165
+			require_once __DIR__.'/../../../settings/routes.php';
166
+			require_once __DIR__.'/../../../core/routes.php';
167 167
 
168 168
 			// Also add the OCS collection
169 169
 			$collection = $this->getCollection('root.ocs');
170 170
 			$collection->addPrefix('/ocsapp');
171 171
 			$this->root->addCollection($collection);
172 172
 		}
173
-		\OC::$server->getEventLogger()->end('loadroutes' . $requestedApp);
173
+		\OC::$server->getEventLogger()->end('loadroutes'.$requestedApp);
174 174
 	}
175 175
 
176 176
 	/**
@@ -241,14 +241,14 @@  discard block
 block discarded – undo
241 241
 	public function match($url) {
242 242
 		if (substr($url, 0, 6) === '/apps/') {
243 243
 			// empty string / 'apps' / $app / rest of the route
244
-			list(, , $app,) = explode('/', $url, 4);
244
+			list(,, $app,) = explode('/', $url, 4);
245 245
 
246 246
 			$app = \OC_App::cleanAppId($app);
247 247
 			\OC::$REQUESTEDAPP = $app;
248 248
 			$this->loadRoutes($app);
249 249
 		} else if (substr($url, 0, 13) === '/ocsapp/apps/') {
250 250
 			// empty string / 'ocsapp' / 'apps' / $app / rest of the route
251
-			list(, , , $app,) = explode('/', $url, 5);
251
+			list(,,, $app,) = explode('/', $url, 5);
252 252
 
253 253
 			$app = \OC_App::cleanAppId($app);
254 254
 			\OC::$REQUESTEDAPP = $app;
@@ -272,7 +272,7 @@  discard block
 block discarded – undo
272 272
 				// However, since Symfony does not allow empty route names, the route
273 273
 				// we need to match is '/', so we need to append the '/' here.
274 274
 				try {
275
-					$parameters = $matcher->match($url . '/');
275
+					$parameters = $matcher->match($url.'/');
276 276
 				} catch (ResourceNotFoundException $newException) {
277 277
 					// If we still didn't match a route, we throw the original exception
278 278
 					throw $e;
@@ -362,7 +362,7 @@  discard block
 block discarded – undo
362 362
 		if (is_array($routes)) {
363 363
 			$appNameSpace = App::buildAppNamespace($appName);
364 364
 
365
-			$applicationClassName = $appNameSpace . '\\AppInfo\\Application';
365
+			$applicationClassName = $appNameSpace.'\\AppInfo\\Application';
366 366
 
367 367
 			if (class_exists($applicationClassName)) {
368 368
 				$application = new $applicationClassName();
Please login to merge, or discard this patch.