Execute the route action with the given strategy.

@throws BadRouteException
@return mixed
969597
private function callWithStrategy()
    {
        if ($this->strategy instanceof StrategyInterface) {
            if ($this->strategy instanceof MatcherAwareInterface) {
                $this->strategy->setMatcher($this->matcher);
            }

            return $this->strategy->call($this);
        }

        throw new BadRouteException(str_replace("%s", get_class($this->strategy), BadRouteException::BAD_STRATEGY));
    }
177116
public function run()
    {
        //check sub controller
        foreach ($this->controllers as $controller) {
            if ($result = $controller->run()) {
                return $result;
            }
        }

        $requestedUrl = $this->getClient()->getUrl();
        $this->normalizeUrl($requestedUrl);
        //check if its in our area
        if (strpos($requestedUrl, $this->triggerUrl) !== 0) return;

        $endPos = $this->triggerUrl === '/' ? 1 : strlen($this->triggerUrl) + 1;
        $uri = substr($requestedUrl, $endPos);

        if (!$uri) $uri = '';

        $route = false;
        $arguments = array();
        $requiredMethod = $this->getClient()->getMethod();

        //does the requested uri exist?
        list($callableMethod, $regexArguments, $method, $routeUri) = $this->findRoute($uri, $requiredMethod);

        if ((!$callableMethod || $method != 'options') && $requiredMethod == 'options') {
            $description = $this->describe($uri);
            $this->send($description);
        }

        if (!$callableMethod) {
            if (!$this->getParentController()) {
                if ($this->fallbackMethod) {
                    $m = $this->fallbackMethod;
                    $this->send($this->controller->$m());
                } else {
                    return $this->sendBadRequest('RouteNotFoundException', "There is no route for '$uri'.");
                }
            } else {
                return false;
            }
        }

        if ($method == '_all_')
            $arguments[] = $method;

        if (is_array($regexArguments)) {
            $arguments = array_merge($arguments, $regexArguments);
        }

        //open class and scan method
        if ($this->controller && is_string($callableMethod)) {
            $ref = new \ReflectionClass($this->controller);

            if (!method_exists($this->controller, $callableMethod)) {
                $this->sendBadRequest('MethodNotFoundException', "There is no method '$callableMethod' in ".
                    get_class($this->controller).".");
            }

            $reflectionMethod = $ref->getMethod($callableMethod);
        } else if (is_callable($callableMethod)) {
            $reflectionMethod = new \ReflectionFunction($callableMethod);
        }

        $params = $reflectionMethod->getParameters();

        if ($method == '_all_') {
            //first parameter is $pMethod
            array_shift($params);
        }

        //remove regex arguments
        for ($i=0; $i<count($regexArguments); $i++) {
            array_shift($params);
        }

        //collect arguments
        foreach ($params as $param) {
            $name = $this->argumentName($param->getName());

            if ($name == '_') {
                $thisArgs = array();
                foreach ($_GET as $k => $v) {
                    if (substr($k, 0, 1) == '_' && $k != '_suppress_status_code')
                        $thisArgs[$k] = $v;
                }
                $arguments[] = $thisArgs;
            } else {

                if (!$param->isOptional() && !isset($_GET[$name]) && !isset($_POST[$name])) {
                    return $this->sendBadRequest('MissingRequiredArgumentException', sprintf("Argument '%s' is missing.", $name));
                }

                $arguments[] = isset($_GET[$name]) ? $_GET[$name] : (isset($_POST[$name]) ? $_POST[$name] : $param->getDefaultValue());
            }
        }

        if ($this->checkAccessFn) {
            $args[] = $this->getClient()->getUrl();
            $args[] = $route;
            $args[] = $arguments;
            try {
                call_user_func_array($this->checkAccessFn, $args);
            } catch (\Exception $e) {
                $this->sendException($e);
            }
        }

        //fire method
        $object = $this->controller;

        return $this->fireMethod($callableMethod, $object, $arguments);

    }
1010014
protected function runRoute()
  {
    # Get Method and URI
    $httpMethod = $this->getRequest()->getMethod();
    $path = $this->getRequest()->getUri()->getPath();
    $routeInfo = null;
    $response = null;

    # Find route match in groups
    foreach ($this->getRouteGroups() as $routeGroup)
    {
      # Match the METHOD and URI to the routes in this group
      $routeInfo = $routeGroup->matchRoute($httpMethod,$path);

      if ( \count($routeInfo)>0 ) {
        # Debug log
        $this->getLogger()->debug('Route matched ',['path'=>$path,'handler'=>$routeInfo['handler']]);

        # Run Before Hooks
        // $ok = $this->runHooks('OnBeforeRequest');

        $beforeResult = true; // assume all before handlers succeed
        $routeResult = false;
        $afterResult = true; // assume all after handlers succeed

        #
        # Run the Common AND Groups Before Middlewares (ServerRequestInterface)
        #
        $beforeMiddleware = \array_merge($this->beforeMiddleware, $routeGroup->getBeforeMiddleware());

        foreach ($beforeMiddleware as $middleware)
        {
          if (\class_exists($middleware) ) {
            $beforeHandler = new $middleware($routeInfo['args']);

            # Debug log
            $this->getLogger()->debug('Initialize Before middleware',['rid'=>container('requestId'),'middleware'=>$middleware]);

            # Initialize
            $beforeHandler->initialize($routeInfo['args']);

            # Debug log
            $this->getLogger()->debug('Running Before middleware',['rid'=>container('requestId'),'middleware'=>$middleware]);

            if (!$beforeHandler->handle($routeInfo['args'])) {
              # Record outcome
              $beforeResult = false;

              # Stop processing more middleware
              break;
            }
          } else {
            # Log
            $this->getLogger()->warning('Before Middleware not found',['rid'=>container('requestId'),'middleware'=>$middleware]);
          }
        }

        #
        # Create & Run the Controller Class - If the Before Middlewares where ok!
        #
        if ($beforeResult) {
          # Extract class & method
          $arr = \explode('@',$routeInfo['handler']);
          $handlerClass = $arr[0];
          $handlerMethod = ($arr[1] ?? 'handle');

          # Check existance of handler class
          if (\class_exists($handlerClass))
          {
            # Create the class
            $routeHandler = new $handlerClass( $routeInfo['args'] );

            # Check method existance
            if ($routeHandler && \method_exists($routeHandler,'initialize') && \method_exists($routeHandler,$handlerMethod))
            {
              # Debug log
              $this->getLogger()->debug('Running controller->initialize()',[
                'rid' => \container('requestId'),
                'controller'=>$handlerClass
              ]);

              # Initialize
              $routeHandler->initialize($routeInfo['args']);

              # Debug log
              $this->getLogger()->debug('Running controller->handle()',[
                'rid' => \container('requestId'),
                'method'=>$handlerMethod
              ]);

              # Run Controller's method
              $response = $routeHandler->$handlerMethod($routeInfo['args']);

              # Set it
              if ($response)
                $this->setResponse($response);

            } else {
              # Log
              $this->getLogger()->error('Method not found in controller ',[
                'rid' => \container('requestId'),
                'controller'=>$handlerClass,
                'method'=>$handlerMethod
              ]);
            }

          } else {
            # Debug log
            $this->getLogger()->error('Controller not found ',[
              'rid' => \container('requestId'),
              'controller'=>$handlerClass
            ]);

            # Attempt to run the 404 error controller (if set by user in config)
            $this->runErrorController('',404);
          }
        }

        #
        # Run the After Middlewares (ServerRequestInterface)
        #
        $afterMiddleware = \array_merge($this->afterMiddleware,$routeGroup->getAfterMiddleware());
        foreach ($afterMiddleware as $middleware)
        {
          if (\class_exists($middleware) ) {
            $afterHandler = new $middleware($routeInfo['args']);

            # Debug log
            $this->getLogger()->debug('Initialize After middleware',[
              'rid' => \container('requestId'),
              'middleware'=>$middleware
            ]);

            # Initialize
            $afterHandler->initialize($routeInfo['args']);

            # Debug log
            $this->getLogger()->debug('Running After middleware',[
              'rid' => \container('requestId'),
              'middleware'=>$middleware
            ]);

            if (!$afterHandler->handle($routeInfo['args'])) {

              return false;
            }

          } else {
            # Log
            $this->getLogger()->warning('After Middleware not found',[
              'rid' => \container('requestId'),
              'middleware'=>$middleware
            ]);
          }
        }

        # Run After Hooks
        // $ok = $this->runHooks('OnAfterRequest');

        # Return the generated response
        return $this->getResponse();

      } // if count() ...

    } // foreach routeGroup

    ##
    ## No route matched the request ?!
    ##
    $this->getLogger()->notice('No route matched the request',[
      'method' => $this->getRequest()->getMethod(),
      'path' => $path,
      'ip' => \getClientIp(),
    ]);

    ##
    ## Try to load the "errors" controllers in the routes-{env}.json file
    ## and run the appropriate HTTP Code controller. If not found
    #W we will try to load the 4xx or 5xx generic controller (if defined)
    ##

    return $this->runErrorController('', 404);
  }
216706
public function execute()
    {
        $request = $this->initGraphqlRequest();
        $response = $request->postRaw(
            $this->buildPayload()
        );
        if ($response->getCode() !== 200) {
            throw ExceptionBuilder::fromHttpRequestAndResponse($request, $response);
        }

        return ResultSetBuilder::fromHttpResponse($response);
    }
210161
public function fire()
	{
		if (count($this->routes) == 0)
		{
			return $this->error("Your application doesn't have any routes.");
		}

		$this->displayRoutes($this->getRoutes());
	}
874705
public function strategy($strategy = null)
    {
        if (is_null($strategy)) {
            $strategy = $this->defaultStrategy ?: OrderStrategy::class;
        }

        if (!class_exists($strategy)) {
            $strategy = __NAMESPACE__ . '\strategies\\' . ucfirst($strategy);
        }

        if (!class_exists($strategy)) {
            throw new InvalidArgumentException("Unsupported strategy \"{$strategy}\"");
        }

        if (empty($this->strategies[$strategy]) || !($this->strategies[$strategy] instanceof StrategyInterface)) {
            $this->strategies[$strategy] = new $strategy($this);
        }

        return $this->strategies[$strategy];
    }
1274649
public function getAction()
    {
        if (is_null($this->_action)) {
            $action =  $this->getConfiguration()
                ->get('router.action', 'index');
            if (isset($this->_params['action'])) {
                $action = $this->_params['action'];
            }
            $this->_action = $action;
        }
        return $this->_action;
    }
1131085
protected function currentAction()
    {
        $action = substr($action = Route::currentRouteAction(), strpos($action, '@') + 1);

        if (!method_exists($this, $action)) {
            $action = 'index';
        }

        return $action;
    }
373854
public function handle()
    {
        $this->bootstrap();

        $middleware = array_merge(
            $this->middleware,
            $this->router->getRouteMiddleware()
        );

        return $this->sendThroughPipeline($middleware, function () {
            return $this->router->execute($this);
        });
    }
578316
public function run()
    {
        $this->init();
        try {
            $this->bootstrap();
            $this->route();
            $this->dispatch();
        } catch (Exception $e) {
            if (APPLICATION_ENV == self::ENV_DEV) {
                var_dump($e);
            } else {
                throw $e;
            }
        }
        return $this;
    }
408117
public function currentRouteAction()
	{
		if ( ! $this->current()) return;

		$action = $this->current()->getAction();

		return isset($action['controller']) ? $action['controller'] : null;
	}
240827
public function performRoute()
    {
        $task = $this->getServiceProvider()->getServiceInstance($this->options['task']);
        if (false === method_exists($task, $this->options['action'])) {
            throw new ResourceNotFoundException(
                sprintf(
                    '%s task does not have action %s.',
                    $this->options['task'],
                    $this->options['action']
                )
            );
        }

        // call the task's init function
        if ($task instanceof TaskInterface) {
            $task->init($this->options);
        }

        $taskParams = array_splice($_SERVER['argv'], 5);
        $action = $this->options['action'];
        return $task->$action($taskParams);
    }
397508
public function send() {

		if ( is_null( $this->strategy ) ) {
			throw new \LogicException( "No strategy has been set." );
		}

		return $this->strategy->send( $this->get_recipient(), $this->get_message(), $this->get_subject(), $this->get_tags() );
	}
1258536
public function setStrategy($strategy)
    {
        foreach ($this->routes as $route)
            $route->setStrategy($strategy);
        return $this;
    }
1315378
public function handle()
    {
        if (empty($this->routes)) {
            return $this->error("Your application doesn't have any routes.");
        }

        if (empty($routes = $this->getRoutes())) {
            return $this->error("Your application doesn't have any routes matching the given criteria.");
        }

        $this->displayRoutes($routes);
    }
684591
private function runRouteBinding(): void
    {
        // calculated depend of language
        $pathway = $this->getPathInfo();
        /** @var array $routing */
        $routing = App::$Properties->getAll('Routing');

        // try to work with static aliases
        if (Any::isArray($routing) && isset($routing['Alias'], $routing['Alias'][env_name])) {
            $pathway = $this->findStaticAliases($routing['Alias'][env_name], $pathway);
        }

        $this->setPathdata(explode('/', trim($pathway, '/')));

        // set default controller and action for undefined data
        if (!$this->action) {
            $this->action = 'Index';
        }

        // empty or contains backslashes? set to main
        if (!$this->controller || Str::contains('\\', $this->controller)) {
            $this->controller = 'Main';
        }

        // find callback injection in routing configs (calculated in App::run())
        if (Any::isArray($routing) && isset($routing['Callback'], $routing['Callback'][env_name])) {
            $this->findDynamicCallbacks($routing['Callback'][env_name], $this->controller);
        }
    }
776176
public function fire() {
        $rows          = [];
        $real_progress = 0;
        $idx           = 0;
        $last          = null;
        $items         = [];
        foreach (\Route::getRoutes() as $r => $route) {
//            if (!\Larakit\Route\Route::isEnable($route->getName())) {
//                continue;
//            }
            /**
             * @var Route $route
             */
            $item    = [];
            $action  = $route->getActionName();
            $_action = explode('@', $action);
            $method  = Arr::get($_action, 1);
            $class   = Arr::get($_action, 0);
            //            if (($action != 'Closure') && (strpos($action, 'Larakit') === false))
            //                continue;
            if ('Closure' == $action) {
                $progress = 100;
            }
            else {
                if (is_callable(explode('@', $action))) {
                    $readiness = (int)\Larakit\Route\Route::_($route->getName(), 'readiness');
                    if (!$readiness) {
                        $readiness = 1;
                    }
                    $progress = $readiness;
                }
                else {
                    $progress = 0;
                }
            }
            $idx++;
            $real_progress += $progress;
            switch (true) {
                case $progress < 50:
                    $style = 'error';
                    break;
                case $progress < 100:
                    $style = 'question';
                    break;
                default:
                    $style = 'info';
                    break;
            }
            $item[] = $this->wrap($route->domain(), $style);
            $item[] = $this->wrap(implode('|', $route->getMethods()), $style);
            $item[] = $this->wrap($route->getUri(), $style);
            $item[] = $this->wrap($route->getName(), $style);
            if ('Closure' == $action) {
                $item[] = $this->wrap('\Closure', $style);
                $item[] = '';
            }
            else {
                $item[] = $this->wrap($class, $style);
                $item[] = $this->wrap($method, $style);
            }
            $item[] = $this->wrap($idx, $style, 3);
            $item[] = $this->wrap($progress . '%', $style, 9);
            $v      = mb_strpos($route->getName(), '::') ? explode('::', $route->getName()) : [];
            $vendor = Arr::get($v, 0, 'app');
            //            $item[]      = $vendor;

            if (($last != $vendor)) {
                if (!(is_null($last))) {
                    $rows[] = new TableSeparator();
                }
                $last = $vendor;
            }
            $items[$route->getName()] = $item;
        }

        $last = null;
        $rows = [];
        $idx = 0;
        foreach ($items as $route => $row) {
            $idx++;
            $v      = mb_strpos($route, '::') ? explode('::', $route) : [];
            $vendor = Arr::get($v, 0, 'app');
            if (($last != $vendor)) {
                if (!(is_null($last))) {
                    $rows[] = new TableSeparator();
                }
                $last = $vendor;
            }
            $rows[] = [$idx] + $row;
        }
        //        foreach($)
        $this->table(
            [
                'Domain',
                'Method',
                'URI',
                'RouteName',
                'Controller',
                'Action',
                '#',
                'Readiness',
            ],
            $rows
        );
        $progress_all  = count($rows) * 100;
        $real_progress = $real_progress / $progress_all * 100;
        $this->info('Общая готовность: ' . number_format($real_progress, 2) . '%');
        $this->info(
            '[' . str_pad(
                str_repeat('#', (int)$real_progress) . ($real_progress != 100 ? '>' : ''),
                100,
                '-',
                STR_PAD_RIGHT
            ) . ']'
        );
    }