aboutsummaryrefslogtreecommitdiffstats
path: root/lib/private/Route
diff options
context:
space:
mode:
authorRoeland Jago Douma <roeland@famdouma.nl>2020-07-01 09:45:46 +0200
committerRoeland Jago Douma <roeland@famdouma.nl>2020-07-07 12:33:22 +0200
commitedc1c77dd917e232840084dd3917df62c06eb25b (patch)
tree61e75d849e068403d43bf3af61c8b54816b695c6 /lib/private/Route
parentcd7a6276f27e641cfa8f835c53cd3781e69d1d67 (diff)
downloadnextcloud-server-edc1c77dd917e232840084dd3917df62c06eb25b.tar.gz
nextcloud-server-edc1c77dd917e232840084dd3917df62c06eb25b.zip
Do not create a RouteActionHandler object for each route
This is not required and doesn't allow us to be properly lazy. On top of it this doesnt allow us to cache the routes (since closures/objects can't be cached). This is the first small step into cleaning up the routing we have Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
Diffstat (limited to 'lib/private/Route')
-rw-r--r--lib/private/Route/Router.php28
1 files changed, 19 insertions, 9 deletions
diff --git a/lib/private/Route/Router.php b/lib/private/Route/Router.php
index 0e436339013..3bb29961454 100644
--- a/lib/private/Route/Router.php
+++ b/lib/private/Route/Router.php
@@ -288,7 +288,12 @@ class Router implements IRouter {
}
\OC::$server->getEventLogger()->start('run_route', 'Run route');
- if (isset($parameters['action'])) {
+ if (isset($parameters['caller'])) {
+ $caller = $parameters['caller'];
+ unset($parameters['caller']);
+ $application = $this->getApplicationClass($caller[0]);
+ \OC\AppFramework\App::main($caller[1], $caller[2], $application->getContainer(), $parameters);
+ } elseif (isset($parameters['action'])) {
$action = $parameters['action'];
if (!is_callable($action)) {
throw new \Exception('not a callable action');
@@ -394,17 +399,22 @@ class Router implements IRouter {
*/
private function setupRoutes($routes, $appName) {
if (is_array($routes)) {
- $appNameSpace = App::buildAppNamespace($appName);
+ $application = $this->getApplicationClass($appName);
+ $application->registerRoutes($this, $routes);
+ }
+ }
- $applicationClassName = $appNameSpace . '\\AppInfo\\Application';
+ private function getApplicationClass(string $appName) {
+ $appNameSpace = App::buildAppNamespace($appName);
- if (class_exists($applicationClassName)) {
- $application = \OC::$server->query($applicationClassName);
- } else {
- $application = new App($appName);
- }
+ $applicationClassName = $appNameSpace . '\\AppInfo\\Application';
- $application->registerRoutes($this, $routes);
+ if (class_exists($applicationClassName)) {
+ $application = \OC::$server->query($applicationClassName);
+ } else {
+ $application = new App($appName);
}
+
+ return $application;
}
}