@param       $name
@param       $controller
@param       $action
@param array $options

@return bool
176622
protected function setResourceDelete($name, $controller, $action, $options = [])
    {
        return $this->mapResource('delete', $name . '/(\d+)/', $controller, $action, true);
    }
869019
private function _createRoute( $controller_name, $action_name )
    {
        $route = new Router\Route();

        $route->setControllerName( $controller_name );
        $route->setActionName( $action_name );

        return $route;
    }
101238
public function setController($name, $controller=null)
	{
	    if ($name instanceof Controller) {
	        $controller = $name;
	        $sname = $controller->getName();
	    } elseif ($controller instanceof Controller) {
	        $sname = $name && !is_numeric($name) ? $name : $controller->getName();
	    } else {
	        if ($controller) {
	            $class_name = Ioc::findClass($controller, 'controller');
	        } else {
	            $class_name = Ioc::findClass($name, 'controller');
	        }
	        
	        if ($class_name && is_subclass_of($class_name, "\\Wslim\\Console\\Controller")) {
	            $sname = is_numeric($name) ? null : $name;
	            $controller =  new $class_name($sname);
	            if (!$sname) {
	                $sname = $controller->getName();
	            }
	        } else {
	            throw new \LogicException(sprintf('Controller class "%s" is not exists.', $controller));
	        }
	    }
	    
	    if (!$controller->isEnabled()) {
	        return;
	    }
	    
	    if (null === $controller->getDefinition()) {
	        throw new \LogicException(sprintf('Controller class "%s" is not correctly initialized. You probably forgot to call the parent constructor.', get_class($controller)));
	    }
	    
	    $this->controllers[$sname] = $controller;
	    
	    foreach ($controller->getAliases() as $alias) {
	        $this->controllers[$alias] = $controller;
	    }
	    
	    return $controller;
	}
1285946
public function make(Name $name, array $options): string
    {
        $options = (new Map($options))->filter(function ($key, $value) {
            return !$value->isExceptional();
        });

        return $this->url($name, $options);
    }
1016266
protected function addResourceUpdate( $name, $base, $controller, $options )
	{
		$uri = $this->getResourceUri( $name ) . '/{' . $base . '';

		$action = $this->getResourceAction( $name, $controller, 'update', $options );

		$this->router->match( ['PUT', 'PATCH'], $uri, $action );
	}
1082003
public function resource($name, $controller, array $options = array())
    {
        $registrar = $this->getRegistrar();

        $registrar->register($name, $controller, $options);
    }
1144751
public function parseControllerName($name)
	{
		if (strpos($name, ':') === false) {
			throw new \Exception(sprintf('Unparsable controller name "%s", it should have at least one ":"', $name));
		}

		$parts = explode(':', $name);

		if (count($parts) == 2) {
			list($class, $action) = $parts;

			$action = $action.'Action';

			if (!class_exists($class)) {
				throw new \Exception(sprintf('Controller class "%s" not found', $class));
			}

			if (!method_exists($class, $action)) {
				throw new \Exception(sprintf('Controller method "%s" does not exist for controller class "%s"', $action, $class));
			}

			return array(
				'controller' => $class,
				'action' => $action
			);
		}

		if (count($parts) == 3) {
			list($package, $controller, $action) = $parts;

			$action = $action.'Action';

			$packageName = $this->resolvePackage($package);

			$parts = explode('\\', $packageName);

			array_pop($parts);

			$namespace = implode('\\', $parts);

			return array(
				'controller' => '\\'.$namespace.'\\Controller\\'.$controller.'Controller',
				'action' => $action
			);
		}

		throw new \Exception(sprintf('Too many chunks in your controller name (got "%s")', implode(', ', $parts)));
	}
72994
public static function hasAccess(User $user, $controller, $action, $parameters) {
        $access = true;
        foreach (self::getImplementations() as $impl) {
            $access = $access && $impl->hasAccess($user, $controller, $action, $parameters);
        }
        return $access;
    }
851153
public function resource($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.
		$base = $this->getResourceWildcard(last(explode('.', $name)));

		$defaults = $this->resourceDefaults;

		foreach ($this->getResourceMethods($defaults, $options) as $m)
		{
			$this->{'addResource'.ucfirst($m)}($name, $base, $controller, $options);
		}
	}
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);
        }
    }
32337
public function resource($name, $controller, array $options = [])
    {
        if ($this->container->bound(ResourceRegistrar::class)) {
            $registrar = $this->container->make(ResourceRegistrar::class);
        } else {
            $registrar = new ResourceRegistrar($this);
        }

        $registrar->register($name, $controller, $options);
    }
580395
private function _callAction(Controller $controller, $action, $error)
    {
        if ($error) {
            $method = $this->actionChain->actionNameStrategy($action . '_' . $error);
        } else {
            $method = $this->actionChain->actionNameStrategy($action);
        }
        if (method_exists($controller, $method)) {
            return $controller->$method();
        } else {
            return $error;
        }
    }
300949
public function action(string $action, string $controller)
    {
        $this->options['actions'][strtolower($action)] = $controller;

        return $this;
    }
1040478
public function options($pattern, $action, $name = null)
    {
        return $this->addRoute(['OPTIONS'], $pattern, $action, $name);
    }
417691
protected function _loadAction($name)
    {
        if (!isset($this->_actionInstances[$name])) {
            $config = $this->getConfig('actions.' . $name);

            if (empty($config)) {
                throw new ActionNotConfiguredException(sprintf('Action "%s" has not been mapped', $name));
            }

            $className = App::className($config['className'], 'Action', 'Action');
            if (empty($className)) {
                throw new MissingActionException('Could not find action class: ' . $config['className']);
            }

            $this->_actionInstances[$name] = new $className($this->_controller);
            unset($config['className']);
            $this->_actionInstances[$name]->setConfig($config);
        }

        return $this->_actionInstances[$name];
    }
61725
private function invokeAction(Controller $controller, string $actionName): void
    {
        // 获取操作结果
        $actionMethodName = $actionName;
        $actionMethodPrefix = $this->config->getValue('ACTION_METHOD_PREFIX');
        if (! empty($actionMethodPrefix)) {
            $actionMethodName = $actionMethodPrefix . ucfirst($actionMethodName);
        }
        $methods = get_class_methods($controller);
        $actionExists = in_array($actionMethodName, $methods);
        if (! $actionExists) {
            throw new RouteException(get_class($controller) . '中的操作方法' . $actionMethodName . '不存在', 404);
        }
        $actionResult = $controller->invokeAction($actionName, $actionMethodName);
        $this->invokeActionResult($actionResult);
    }
961438
public function setAction(Controller $controller, $action = 'execute')
    {
        $this->controller = $controller;
        $this->action = $action;
    }