Call the different routing methods
@throws \Exception
358529
public function route()
    {
        $this->dashboardRouting($this->relativeCmsUri);
        $this->logOffRouting($this->request, $this->relativeCmsUri);
        $this->apiRouting($this->relativeCmsUri);
        $this->documentRouting($this->userRights, $this->relativeCmsUri);
        $this->valuelistsRouting($this->userRights, $this->relativeCmsUri);
        $this->sitemapRouting($this->userRights, $this->relativeCmsUri);
        $this->redirectRouting($this->userRights, $this->relativeCmsUri);
        $this->imageRouting($this->userRights, $this->relativeCmsUri);
        $this->filesRouting($this->userRights, $this->relativeCmsUri);
        $this->configurationRouting($this->userRights, $this->relativeCmsUri);
        $this->searchRouting($this->relativeCmsUri);
    }
1229078
abstract public function __construct(Request $request, $relativeCmsUri, CmsComponent $cmsComponent);

    /**
     * @param Request $request
     * @param string $relativeCmsUri
     * @param CmsComponent $cmsComponent
     * @throws \Exception
     */
    protected function doRouting($request, $relativeCmsUri, $cmsComponent)
    {
        if (array_key_exists($relativeCmsUri, $this::$routes)) {
            $method = $this::$routes[$relativeCmsUri];
            $this->$method($request, $cmsComponent);
        }
    }
1063141
public function performRoute()
    {
        $this->invokePluginsHook(
            'beforeServiceSelected',
            array($this, $this->getRequest())
        );

        /* Check if we can get the service. */
        try {
            $service = $this->getServiceProvider()->getServiceInstance(
                $this->getRequest()->getController()
            );
        } catch (Exception $e) {
            throw new ResourceNotFoundException(
                'No such service: '.$this->getRequest()->getController()
            );
        }

        /* Loop through each call in the possible batch. */
        $response = array();
        foreach ($this->requests as $request) {
            $callResponse = $this->invokeMethod($service, $request);

            /* Stop here if this isn't a batch. There is only one response. */
            if (false === $this->batch) {
                $response = $callResponse->getResponseObject();
                break;
            }

            /* Omit empty responses from the batch response. */
            if ($callResponse = $callResponse->getResponseObject()) {
                $response[] = $callResponse;
            }
        }

        @header('Content-type: application/json');
        $response = new Response($response);
        return $this->getEncoder()->encode($response);
    }
1344805
public static function run($app)
    {
        $route = Router::process(new Request);

        // Route to 404 if controller and/or method cannot be found
        if (!class_exists($route['controller'])
        or !method_exists($route['controller'], "{$route['method']}Action")) {
            if ($app->environment() == 'development') {
                throw new Exception("Unable to find controller for '" . Request::pathInfo() . "'");
            } else {
                $route = Router::set404();
            }
        }

        // Get method parameters
        $r = new ReflectionMethod("{$route['controller']}::{$route['method']}Action");
        $params = [];

        foreach ($r->getParameters() as $param) {
            if (isset($route['params'][$param->getName()])) {
                $params[] = $route['params'][$param->getName()];
            }
        }
        unset($r, $param);

        static::$controller = new $route['controller']();

        // Run before filters
        $beforeAll    = EventDispatcher::dispatch("before." . $route['controller'] . "::*");
        $beforeAction = EventDispatcher::dispatch("before." . $route['controller'] . "::{$route['method']}");

        if ($beforeAll instanceof Response || $beforeAction instanceof Response) {
            static::$controller->executeAction = false;
            $response = $beforeAll ?: $beforeAction;
        }

        // Execute action
        if (static::$controller->executeAction) {
            $response = call_user_func_array(
                array(static::$controller, $route['method'] . 'Action'),
                $params
            );
        }

        // Run after filters
        $afterAll    = EventDispatcher::dispatch("after." . $route['controller'] . "::*");
        $afterAction = EventDispatcher::dispatch("after." . $route['controller'] . "::{$route['method']}");

        if ($afterAll instanceof Response || $afterAction instanceof Response) {
            $response = $afterAll instanceof Response ? $afterAll : $afterAction;
        }

        // Send response
        if (!$response instanceof Response) {
            throw new Exception("The controller [{$route['controller']}::{$route['method']}] returned an invalid response.");
        } else {
            $response->send();
        }

        // Shutdown the controller
        static::$controller->__shutdown();
    }
116616
public function route(Request $request)
    {
        if ($request instanceof Request\Web) {
            $server = $request->getServer();
            if (!isset($server['REQUEST_URI'])) {
                throw new Exception('REQUEST_URI is not set');
            }
            $this->logger->debug('Routing of web request', ['REQUEST_URI' => $server['REQUEST_URI']]);
            $urlComponents = explode('?', $server['REQUEST_URI']);
            $destination = reset($urlComponents);
            if (strpos($destination, $this->entryPoint) === 0) {
                $destination = substr($destination, strlen($server['SCRIPT_NAME']));
            }
        } elseif ($request instanceof Request\Cli) {
            $argv = $request->getArgv();
            $destination = isset($argv[1]) ? $argv[1] : '/';
            $this->logger->debug('Routing of CLI request', ['argv' => $argv]);
        } elseif ($request instanceof Request\Virtual) {
            $this->logger->debug(
                'Routing of virtual request',
                ['controller' => $request->getController(), 'action' => $request->getAction()]
            );
            return new Route($request->getController(), $request->getAction());
        } else {
            throw new Exception('Request type not supported');
        }

        $destination = trim($destination, '/');
        $destination = empty($destination) ? '/' : $destination;

        $this->logger->debug('Searching for corresponding route', ['destination' => $destination]);

        return $this->getRoute($destination);
    }
1222191
public static function handleRequest() {
        $response = get_response();
        try {
            $routes = self::$routes->getRoutes();
            if (!empty($routes)) {
                $beforeRoutes = self::$beforeRoutes->getRoutes();
                if (!empty($beforeRoutes)) {
                    foreach ($beforeRoutes as $beforeRoute) {
                        self::executeAction($beforeRoute->getAction(), array_merge($_REQUEST, $beforeRoute->getParameters()));
                    }
                }

                try {
                    foreach ($routes as $route) {
                        $routeResult = self::executeAction($route->getAction(), array_merge($_REQUEST, $route->getParameters()));
                        if (isset($routeResult)) {
                            $response->content($routeResult);
                        }
                    }
                    $afterRoutes = self::$afterRoutes->getRoutes();
                    if (!empty($afterRoutes)) {
                        foreach ($afterRoutes as $afterRoute) {
                            $routeResult = self::executeAction($afterRoute->getAction(), array_merge($_REQUEST, $afterRoute->getParameters()));
                            if (isset($routeResult)) {
                                $response->content($routeResult);
                            }
                        }
                    }
                    $response->send();
                }
                catch (ActionNotFoundException $notFoundException) {
                    self::handleRequestNotFound();
                }
            }
            else {
                self::handleRequestNotFound();
            }
        }
        catch (Throwable $ex) {
            self::handleRequestException($ex);
        }
    }
993620
public function boot()
    {
        if ($this->app->getProps() === null) {
            return;
        }

        $routes = [];
        $pathPrefix = $this->app->getProp($this->routesPathPrefixPropName, '');
        $propRoutes = $this->app->getProp($this->routesPropName, []);

        if (!is_array($propRoutes)) {
            throw new \Exception('Routes definitions must be an array!');
        }

        foreach ($this->app->getProp($this->routesPropName, []) as $route) {
            $this->validate($route);
            $routes[] = $this->app->createRoute(
                $route['method'] ?? null,
                $pathPrefix.$route['path'],
                $route['stack']
            );
        }

        $this->app->stack($routes);
    }
208653
public function run() {
		// Setup our default error route responders
		$this->setup_error_routes();

		// To always be RESTful, create a last-hit route responder to respond in our designated format ALWAYS
		Router::route( function( $request, $response, $service, $matches ) {
			// ALWAYS respond with our formatting function
			Router::app()->api_respond();
		});

		// Finally, call "dispatch" to have our App's Router route the request appropriately
		Router::dispatch(
			substr(
				$_SERVER['REQUEST_URI'],
				strlen( rtrim( $this->config['app-meta']['base_url'], '/' ) ) // Remove a potential trailing slash
			)
		);
	}
1159319
public function indexAction() {
        $request = $this->getRequest();
        if (!$request->getParam('id') || !$request->getParam('chunk')) {
            throw new Exception('Not enough parameters: "id" and "chunk" are required.');
        }
        $bb = $this->_initBrowsebox($request);
        $this->view->bb = $bb;
        $this->_helper->layout->setLayout('blank');
    }
1242197
public static function getRoutes()
    {
        if (empty(self::$routes)) {
            // If no routes have been set, try the standard file.
            if (is_readable(self::ROUTES_FILE_LOCATION)) {
                // Decode the JSON routes file into an array.
                self::$routes = json_decode(
                    file_get_contents(self::ROUTES_FILE_LOCATION),
                    true
                );
            }
            // No valid routes have been found.
            if (empty(self::$routes)) {
                throw new Exception('No routes could be obtained. Please check the route configuration file.');
            }
        }

        return self::$routes;
    }
1334981
protected function loadRoutes()
    {
        $this->hook->trigger(self::HOOK_LOAD_ROUTES_BEFORE);
        if ($this->config->get('parable.routes')) {
            foreach ($this->config->get('parable.routes') as $routesClass) {
                $routes = \Parable\DI\Container::create($routesClass);

                if (!($routes instanceof \Parable\Framework\Routing\AbstractRouting)) {
                    throw new \Parable\Framework\Exception(
                        "{$routesClass} does not extend \Parable\Framework\Routing\AbstractRouting"
                    );
                }

                // Load the routes
                $routes->load();
            }
        } else {
            $this->hook->trigger(self::HOOK_LOAD_ROUTES_NO_ROUTES_FOUND);
        }
        $this->hook->trigger(self::HOOK_LOAD_ROUTES_AFTER);
        return $this;
    }
790085
public function execute()
    {
        $request = $this->get('request');
        $router = $this->get('router');
        $response = $this->get('response');

        // Attempt to match the requested route with a registered route
        if ($router->matchRequest($request->route(), $request->httpMethod())) {

            // A match was found - pass any route params to the Request instance
            $request->routeParams($router->params());

            // The closure associated with the matched route
            $closure = $router->getClosure($this);

            // Attempt to call the closure
            if ($closure) {
                // Call the output
                $closure($request, $response);
            } else {
                // There was a problem calling the route's closure
                $response->send(500, 'This route\'s callback is invalid.');
            }

        } else {

            // A route wasn't matched - return a 404
            $response->send(404, 'The requested resource was not found.');
        }
    }
1093495
private function generateRouteName(): string
    {
        if (!array_key_exists($this->actionName, $this->adminConfiguration->getParameter('actions'))) {
            throw new Exception(
                sprintf('Invalid action name %s for admin %s (available action are: %s)',
                    $this->actionName,
                    $this->adminName,
                    implode(', ', array_keys($this->adminConfiguration->getParameter('actions'))))
            );
        }
        $routeName = RoutingLoader::generateRouteName(
            $this->adminName,
            $this->actionName,
            $this->adminConfiguration->getParameter('routing_name_pattern')
        );

        return $routeName;
    }
1331486
public function prepare()
    {
        if ($this->ready) {
            return null;
        }

        $this->ready = true;

        $controller = $this->fullController;

        $methods = get_class_methods($controller);
        $allowedMethods = array_keys(self::$valids);

        $classMethods = array_intersect($methods, $allowedMethods);

        if (empty($classMethods)) {
            throw new Exception($controller . ' controller exists, but is not a valid', 2);
        }

        $contentType = $this->contentType . '; charset=' . $this->charset;

        foreach ($classMethods as $method) {
            $route = empty(self::$valids[$method]) ? false : self::$valids[$method];

            if ($route) {
                Route::set($route[0], $route[1], function ()
                use ($method, $contentType, $controller) {
                    header('Content-Type: ' . $contentType);

                    return call_user_func_array(array(new $controller, $method), func_get_args());
                });
            }
        }
    }
751137
public function checkValidProperties()
    {
        if (!$this->controller && !$this->action && !$this->callable) {
            throw new \Parable\Routing\Exception('Either a controller/action combination or callable is required.');
        }
        if (empty($this->methods)) {
            throw new \Parable\Routing\Exception('Methods are required and must be passed as an array.');
        }
        return $this;
    }
1196188
protected function processRequest()
    {
        $route  = $this[ 'request' ]->getRoute();
        $params = $this[ 'request' ]->getParams();

        $controller = $this[ 'router' ]->createController( $route, $params );

        if ( NULL === $controller )
        {
            throw new RawException( 'Failed to Initialise Controller', 404 );
        }

        $this->controller = $controller;

        /** @var IController $controller */
        $controller->run();
    }
64920
private function checkMethod() {
        if (strpos(self::$currentRoute['method'], '|') !== false) {
            if (!in_array($_SERVER['REQUEST_METHOD'], explode('|', self::$currentRoute['method']))) {
                throw new RouteException(_message(ExceptionMessages::INCORRECT_METHOD, $_SERVER['REQUEST_METHOD']));
            }
        } else if ($_SERVER['REQUEST_METHOD'] != self::$currentRoute['method']) {
            throw new RouteException(_message(ExceptionMessages::INCORRECT_METHOD, $_SERVER['REQUEST_METHOD']));
        }
    }