Get the middlewares for the given controller instance and method.

@param  \Illuminate\Routing\Controller $controller
@param  string $method
@return array
178779
protected function getControllerMiddlewareFromInstance($controller, $method)
    {
        $middleware = $this->router->getMiddleware();

        $results = [];

        foreach ($controller->getMiddleware() as $name => $options) {
            if (!$this->methodExcludedByOptions($method, $options)) {
                $results[$name] = array_get($middleware, $name, $name);
            }
        }

        return $results;
    }
859931
private function executeRouteMiddleware(Route &$route, $position, $method)
    {
        $method = strtoupper($method);

        /** @var Middleware[] $middleware */
        $middleware = array();
        $continue   = true;

        // Get all global middleware's.
        if (isset(
                $this->middleware['global'],
                $this->middleware['global'][$position])
            && count($this->middleware['global'][$position]) > 0) {

            $middleware = array_merge($middleware, $this->middleware['global'][$position]);
        }

        // Group middleware if defined.
        if ($route->getGroup() !== null
            &&  isset($this->middleware[$route->getGroup()],
                $this->middleware[$route->getGroup()][$position])
            && count($this->middleware[$route->getGroup()][$position]) > 0) {
            $middleware = array_merge($middleware, $this->middleware[$route->getGroup()][$position]);
        }


        // Will execute all middleware in order..:
        foreach ($middleware as $trigger)
        {
            if (count($trigger->getMethods()) === 0
            ||  in_array(strtoupper($method), $trigger->getMethods())) {

                if ($this->executeMiddleware($trigger) === false) {
                    $continue = false;
                }
            }
        }

        return $continue;
    }
1017855
protected function callLumenControllerWithMiddleware($instance, $method, $routeInfo, $middleware)
    {
        $middleware = $this->gatherMiddlewareClassNames($middleware);

        return $this->sendThroughPipeline($middleware, function () use ($instance, $method, $routeInfo) {
            return $this->callControllerCallable([$instance, $method], $routeInfo[2]);
        });
    }
1023261
private static function gatherMiddleware(IlluminateRoute $route)
    {
        /** @var  array  $middleware */
        $middleware = $route->middleware();

        return is_callable([$route, 'controllerMiddleware'])
            ? array_unique(array_merge($middleware, $route->controllerMiddleware()), SORT_REGULAR)
            : $middleware;
    }
134750
public function dispatch(Route $route, Request $request, $controller, $method)
	{
		// First we will make an instance of this controller via the IoC container instance
		// so that we can call the methods on it. We will also apply any "after" filters
		// to the route so that they will be run by the routers after this processing.
		$instance = $this->makeController($controller);

		$this->assignAfter($instance, $route, $request, $method);

		$response = $this->before($instance, $route, $request, $method);

		// If no before filters returned a response we'll call the method on the controller
		// to get the response to be returned to the router. We will then return it back
		// out for processing by this router and the after filters can be called then.
		if (is_null($response))
		{
			$response = $this->call($instance, $route, $method);
		}

		return $response;
	}
314990
public function getControllerMethod()
    {
        if (! isset($this->method)) {
            list (, $method) = $this->parseControllerCallback();

            return $this->method = $method;
        }

        return $this->method;
    }
345917
protected function getMiddleware($instance, $method)
	{
		$middleware = $this->router->getMiddleware();

		$results = [];

		foreach ($instance->getMiddleware() as $name => $options)
		{
			if ( ! $this->methodExcludedByOptions($method, $options))
			{
				$results[] = array_get($middleware, $name, $name);
			}
		}

		return $results;
	}
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;
        }
    }
416390
private function getControllerActionAnnotations($controller, $action)
    {
        if ($controller instanceof \Closure) {
            return $this->annotation->readFunction($controller);
        }

        return $this->annotation->readMethod($controller, $action . 'Action');
    }
1141974
private function callControllerMethod(Controller $controller, $method)
    {
        return App::call([$controller, $method], ParameterBag::getParameters());
    }
121881
public function getRoutesParameters($method, $controller, $reflection, $replace = 'Controller'): array
    {
        $actionName = str_replace('Action', '', $method);
        $routeArr = $this->getActionName($actionName);

        $verb = isset($routeArr[0]) && in_array($routeArr[0], $this->verbs) ? $routeArr[0] : 'get';
        /*
        | For deleteAction HTTP verb name act as method name
         */
        $action = isset($routeArr[1]) ? $actionName : $verb . ucfirst($verb);

        $prefix = str_replace($replace, '', Inflector::getClassNameFromNamespace($controller));

        $plain = $this->getPlainUri($action, Inflector::controllerPath($prefix));
        $uri = $this->addUriWildcards($plain, $reflection, $method);

        return [$uri, $verb, $method, $plain];
    }
1063262
public function dispatch( Route $route, Request $request, $controller, $method )
	{
		$instance = $this->makeController( $controller );

		return $this->callWithinStack( $instance, $route, $request, $method );
	}
1211720
public function add($uri, $method, $controller, $action) {
        $this->currentRoute = [
            'uri' => $uri,
            'method' => $method,
            'controller' => $controller,
            'action' => $action,
            'module' => $this->module,
        ];

        if ($this->currentGroupName) {
            $this->virtualRoutes[$this->currentGroupName][] = $this->currentRoute;
        } else {
            $this->virtualRoutes['*'][] = $this->currentRoute;
        }

        return $this;
    }
661272
public static function build($controller)
    {
        $routes = array();
        $actions = self::parseActionMethods($controller);

        foreach ($actions as $actionName => $actionInfo) {
            list($annotations, $meta) = $actionInfo;

            if (isset($annotations['Route'])) {
                $path = $annotations['Route'];
            } else {
                if ($actionName === 'indexAction') {
                    $path = '';
                } else {
                    $path = self::translatePath($actionName); // '/' . preg_replace_callback('/[A-Z]/', function($matches) {
                }
            }

            $route = array($path, $actionName);

            if (isset($annotations['Method'])) {
                $route[] = array('method' => Mux::convertRequestMethodConstant($annotations['Method']));
            } else {
                $route[] = array();
            }
            $routes[] = $route;
        }

        return $routes;
    }
475516
protected function getResourceAction($resource, $controller, $method, $options)
    {
        $name = $this->getResourceName($resource, $method, $options);

        return array('as' => $name, 'uses' => $controller .'@' .$method);
    }
951363
public function getAppControllersMethod($methodName, $scope = '')
    {
        $methods = [];
        
        if ($this->appControllerRefls) {
            foreach ($this->appControllerRefls as $appRefl) {
                if ($appRefl->hasMethod($methodName)) {
                    $method = $appRefl->getMethod($methodName);
                    
                    if ($this->isApplicationController($method->getDeclaringClass()->getName())) {
                        if ($scope) {
                            $isScope = 'is' . ucfirst($scope);
                            if (!$method->$isScope()) {
                                continue;
                            }
                        }
                        $methods[] = $method->getClosure($this);
                    }
                }
            }
        }
        
        return $methods;
    }
968843
private function mapArguments(AbstractController $controller, string $method, array $args) : array
    {
        $return = [];

        $reflection = new \ReflectionClass($controller);
        if (!$reflection->hasMethod($method)) {
            throw new \InvalidArgumentException(sprintf(
                "Method '%s' does not exist on '%s' for route '%s'",
                $method,
                get_class($controller),
                $this->currentRoute->getName()
            ));
        }

        $method = $reflection->getMethod($method);

        foreach ($method->getParameters() as $parameter) {
            if (!isset($args[$parameter->getName()]) && $parameter->isOptional() === false) {
                if ($method->getName() === 'init') {
                    continue;
                }

                throw new \InvalidArgumentException(sprintf(
                    "Missing mandatory arguments on controller definition '%s' on '%s'",
                    $parameter->getName(),
                    get_class($controller)
                ));
            }

            $return[$parameter->getName()] = null;

            if (array_key_exists($parameter->getName(), $args) && $args[$parameter->getName()] !== '') {
                $value = $args[$parameter->getName()];

                if ($parameter->getClass() && $parameter->getClass()->getName() == 'Cawa\Date\DateTime') {
                    $value = new DateTime($value);
                }

                $return[$parameter->getName()] = $value;
            } elseif (!array_key_exists($parameter->getName(), $args)) {
                $return[$parameter->getName()] = $parameter->getDefaultValue();
            }
        }

        return $return;
    }