From 053ee7b3860c352004bede82d040b4bd34ecb072 Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Mon, 21 Jan 2019 12:02:30 +0100 Subject: Only load routes of the app which is requested * Add fallback to load all routes if needed * Move partial loaded routes test to proper place Signed-off-by: Morris Jobke --- lib/private/Route/Router.php | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) (limited to 'lib') diff --git a/lib/private/Route/Router.php b/lib/private/Route/Router.php index 6de581ffa96..ec91e08472c 100644 --- a/lib/private/Route/Router.php +++ b/lib/private/Route/Router.php @@ -346,13 +346,27 @@ class Router implements IRouter { public function generate($name, $parameters = [], $absolute = false) { + $referenceType = UrlGenerator::ABSOLUTE_URL; + if ($absolute === false) { + $referenceType = UrlGenerator::ABSOLUTE_PATH; + } + $name = $this->fixLegacyRootName($name); + if (strpos($name, '.') !== false) { + list($appName, $other) = explode('.', $name, 3); + // OCS routes are prefixed with "ocs." + if ($appName === 'ocs') { + $appName = $other; + } + $this->loadRoutes($appName); + try { + return $this->getGenerator()->generate($name, $parameters, $referenceType); + } catch (RouteNotFoundException $e) { + } + } + + // Fallback load all routes $this->loadRoutes(); try { - $referenceType = UrlGenerator::ABSOLUTE_URL; - if ($absolute === false) { - $referenceType = UrlGenerator::ABSOLUTE_PATH; - } - $name = $this->fixLegacyRootName($name); return $this->getGenerator()->generate($name, $parameters, $referenceType); } catch (RouteNotFoundException $e) { $this->logger->logException($e, ['level' => ILogger::INFO]); -- cgit v1.2.3