Register a controller.

@param string $uri
@param string $controller
@param array  $names

@return void
19389
public function controller($uri, $controller, $names = [])
    {
        $arr = explode('\\', $controller);
        $controllerClassName = $arr[  sizeof($arr) -1  ];
        $routable = (new ControllerInspector)->getRoutable($this->addGroupNamespace($controller), $uri);
        foreach ($routable as $method => $routes) {
            if ($method == 'getMethodProperties') {
                continue;
            }

            foreach ($routes as $route) {
//  original code
//                $this->{$route['verb']}($route['uri'], [
//                        'uses' => $controller.'@'.$method,
//                        'as' => array_get($names, $method)
//                ]);
//                Route::{$route['verb']}( $route['uri'] ,  "{$controller}@{$method}" );

// should add middleware support later
                Route::{$route['verb']}( $route['uri'] ,  "{$controllerClassName}@{$method}" );

// middleware support not working as following
//                Route::{$route['verb']}( $route['uri'] ,  [
//                    'uses' => $controller.'@'.$method,
//                    'as' => array_get($names, $method)
//                ]);
            }
        }
    }
719701
public function all(string $uri, string $controller, string $action)
    {
        $this->addRoute('ALL', $uri, $controller, $action);
    }
410281
protected function registerControllers()
    {
        $this['controllers.page'] = function ($app) { return new PageController($app); };
        $this['controllers.imagine'] = function ($app) { return new ImagineController($app); };
        $this['controllers.error'] = function ($app) { return new ErrorController($app); };
    }
526012
public function registerNamespace($prefix, $uri)
    {
        $this->initializeXPath();
        $this->xpath->registerNamespace($prefix, $uri);
    }
1055786
private function registerControllerFilters($controller, $controllerService, $filters)
    {
        foreach ($filters as $filter) {
            if ($filter instanceof Before) {
                foreach ($filter->methods as $method) {
                    $this->registerFilter($method, 'before', $controller, $controllerService);
                }
            }

            if ($filter instanceof After) {
                foreach ($filter->methods as $method) {
                    $this->registerFilter($method, 'after', $controller, $controllerService);
                }
            }
        }
    }
651167
public function registerXPathNamespace($prefix, $uri)
    {
        $this->el->registerXPathNamespace($prefix, $uri);
        $this->namespaces[$prefix] = $uri;
    }
1126367
public function get(string $uri, string $controller, string $action)
    {
        $this->addRoute('GET', $uri, $controller, $action);
    }
1200021
public function register($name, $controller, array $options = array())
    {
        // If the resource name contains a slash, we will assume the developer wishes to
        // register these resource routes with a prefix so we will set that up out of
        // the box so they don't have to mess with it. Otherwise, we will continue.
        if (Str::contains($name, '/')) {
            $this->prefixedResource($name, $controller, $options);

            return;
        }

        // We need to extract the base resource from the resource name. Nested resources
        // are supported in the framework, but we need to know what name to use for a
        // place-holder on the route wildcards, which should be the base resources.
        $segments = explode('.', $name);

        $base = $this->getResourceWildcard(
            last($segments)
        );

        $methods = $this->getResourceMethods($this->resourceDefaults, $options);

        foreach ($methods as $method) {
            $method = 'addResource' .ucfirst($method);

            call_user_func(array($this, $method), $name, $base, $controller, $options);
        }
    }
1011633
private function bakeController(string $name) : void
    {
        $this->pathFragment = 'Controller/';

        $this->bake($name, 'Controller/controller', ['name' => $name], 'Controller');
    }
239252
public function addPost(string $uri, string $handler, string $name = null)
    {
        $this->addRoute("POST", $uri, $handler, $name);
    }
57156
public function initialize(Controller $controller) {
		$this->_controller = $controller;
		$this->_model = $this->_controller->{$this->_controller->modelClass};
		if (!$this->_controller->Components->loaded('RequestHandler')) {
			$this->_controller->RequestHandler = $this->_controller->Components->load('RequestHandler');
			$this->_controller->RequestHandler->initialize($this->_controller);
		}

		$this->_modelConfigTheme = ClassRegistry::init('CakeTheme.ConfigTheme');
	}
973453
public function setController($controller, $name = null)
    {
        $controller = $this->app->normalizeClassName($controller, 'Controller');

        return $this->add($controller, $name);
    }
923684
private function mapsController($controller, $uriapp = NULL, $method = NULL, $parentController = NULL){
        $httpMethod= isset($controller['httpMethod']) ? $controller['httpMethod'] : '*';
        if($parentController != NULL){
            $controller['url']= rtrim($parentController['url'], '/') . '/' . ltrim($controller['url'], '/');
        }
        $maps= UrlUri::mapsActualUrl($controller['url'], $uriapp) && UrlUri::mapsActualMethod($httpMethod, $method);
        if($maps){
            $mapController= array(
                'url' => $controller['url'],
                'httpMethod' => $httpMethod,
                'location' => isset($controller['location']) ? $controller['location'] : NULL,
                'namespace' => isset($controller['namespace']) ? $controller['namespace'] : NULL,
                'class' => isset($controller['class']) ? $controller['class'] : $parentController['class'],
                'method' => isset($controller['method']) ? $controller['method'] : NULL,
                'properties' => isset($controller['properties']) ? $controller['properties'] : array(),
                'middlewares' => isset($controller['middlewares']) ? $controller['middlewares'] : []
            );
            if($parentController != NULL){
                if(! isset($controller['class'])){
                    $mapController['location']= isset($parentController['location']) ? $parentController['location'] : NULL;
                    $mapController['namespace']= isset($parentController['namespace']) ? $parentController['namespace'] : NULL;
                }
                if(isset($parentController['properties'])){
                    $mapController['properties']= array_merge($parentController['properties'], $mapController['properties']);
                }
                if(isset($parentController['middlewares'])){
                    $mapController['middlewares'] = array_merge($parentController['middlewares'], $mapController['middlewares']);
                }
            }
            
            return $mapController;
        }else{
            return NULL;
        }
    }
665974
public static function registerHandler($path, $handler, $name = null)
    {
        $routeInfo             = [
            $path,
            $handler
        ];
        static::$routes[$path] = $routeInfo;
        if (!empty($name)) {
            self::$namedRoutes[$name] = $routeInfo;
        }
    }
439754
public function controllers( array $controllers )
	{
		foreach ( $controllers as $uri => $controller )
			$this->controller( $uri, $controller );
	}
112167
public function connect($url, $name, $controller=null)
	{
		$this->_router->connect($url, $name, $controller);

		// register the controller if one is provided
		if(!is_null($controller))
		{
			$this->_controllers[$name] = $controller;
		}

		return $this;
	}
796189
private function registerControllers()
    {
        $this->_controller = new Controller();
        $this->_controller->load($this->_router,
        $this->_config->get('basepath'));
    }