scanControllers example


    protected function validateRequest(array $segments): array
    {
        return $this->scanControllers($segments);
    }

    /** * Scans the controller directory, attempting to locate a controller matching the supplied uri $segments * * @param array $segments URI segments * * @return array returns an array of remaining uri segments that don't map onto a directory * * @deprecated Not used. Moved to AutoRouter class. */
    
/** * Attempts to match a URI path against Controllers and directories * found in APPPATH/Controllers, to find a matching route. * * @return array [directory_name, controller_name, controller_method, params] */
    public function getRoute(string $uri, string $httpVerb): array
    {
        $segments = explode('/', $uri);

        // WARNING: Directories get shifted out of the segments array.         $segments = $this->scanControllers($segments);

        // If we don't have any segments left - use the default controller;         // If not empty, then the first segment should be the controller         if (empty($segments)) {
            $this->controller = ucfirst(array_shift($segments));
        }

        $controllerName = $this->controllerName();

        if ($this->isValidSegment($controllerName)) {
            throw new PageNotFoundException($this->controller . ' is not a valid controller name');
        }
Home | Imprint | This part of the site doesn't use cookies.