diff options
Diffstat (limited to 'lib')
-rw-r--r-- | lib/private/AppFramework/App.php | 8 | ||||
-rw-r--r-- | lib/private/AppFramework/Routing/RouteConfig.php | 16 |
2 files changed, 23 insertions, 1 deletions
diff --git a/lib/private/AppFramework/App.php b/lib/private/AppFramework/App.php index abb779ca979..5a9fb0c64fc 100644 --- a/lib/private/AppFramework/App.php +++ b/lib/private/AppFramework/App.php @@ -31,6 +31,7 @@ namespace OC\AppFramework; use OC\AppFramework\Http\Dispatcher; use OC\AppFramework\DependencyInjection\DIContainer; +use OC\HintException; use OCP\AppFramework\Http; use OCP\AppFramework\QueryException; use OCP\AppFramework\Http\ICallbackResponse; @@ -81,6 +82,7 @@ class App { * @param string $methodName the method that you want to call * @param DIContainer $container an instance of a pimple container. * @param array $urlParams list of URL parameters (optional) + * @throws HintException */ public static function main(string $controllerName, string $methodName, DIContainer $container, array $urlParams = null) { if (!is_null($urlParams)) { @@ -94,6 +96,12 @@ class App { try { $controller = $container->query($controllerName); } catch(QueryException $e) { + if (strpos($controllerName, '\\Controller\\') !== false) { + // This is from a global registered app route that is not enabled. + [/*OC(A)*/, $app, /* Controller/Name*/] = explode('\\', $controllerName, 3); + throw new HintException('App ' . strtolower($app) . ' is not enabled'); + } + if ($appName === 'core') { $appNameSpace = 'OC\\Core'; } else if ($appName === 'settings') { diff --git a/lib/private/AppFramework/Routing/RouteConfig.php b/lib/private/AppFramework/Routing/RouteConfig.php index 0477f4dc209..c9464f506ae 100644 --- a/lib/private/AppFramework/Routing/RouteConfig.php +++ b/lib/private/AppFramework/Routing/RouteConfig.php @@ -30,6 +30,7 @@ declare(strict_types=1); namespace OC\AppFramework\Routing; use OC\AppFramework\DependencyInjection\DIContainer; +use OCP\AppFramework\App; use OCP\Route\IRouter; /** @@ -155,8 +156,21 @@ class RouteConfig { $controllerName = $this->buildControllerName($controller); $actionName = $this->buildActionName($action); + $appName = $simpleRoute['app'] ?? $this->appName; + + if (isset($simpleRoute['app'])) { + // Legacy routes that need to be globally available while they are handled by an app + // E.g. '/f/{id}', '/s/{token}', '/call/{token}', … + $controllerName = str_replace('controllerController', 'Controller', $controllerName); + if ($controllerName === 'PublicpreviewController') { + $controllerName = 'PublicPreviewController'; + } else if ($controllerName === 'RequesthandlerController') { + $controllerName = 'RequestHandlerController'; + } + $controllerName = App::buildAppNamespace($appName) . '\\Controller\\' . $controllerName; + } - $routeName = $this->appName . '.' . $controller . '.' . $action . $postfix; + $routeName = $appName . '.' . $controller . '.' . $action . $postfix; // register the route $handler = new RouteActionHandler($this->container, $controllerName, $actionName); |