@param IRoute $route
@param IContainer $container

@return mixed
186145
public function invoke(IRoute $route, IContainer $container) {
        return $container->call(
            $route->getAction(), $route->getParameters()
        );
    }
799741
private static function invalidRequestHandler(ContainerInterface $container): InvalidRequestHandlerInterface
    {
        if (!$container->has(InvalidRequestHandlerInterface::class)) {
            return new InvalidRequestHandler();
        }

        return $container->get(InvalidRequestHandlerInterface::class);
    }
821050
public static function resolveForRoute($container, $route)
    {
        $parameters = $route->parameters();

        foreach ($route->signatureParameters(UrlRoutable::class) as $parameter) {
            if (! $parameterName = static::getParameterName($parameter->name, $parameters)) {
                continue;
            }

            $parameterValue = $parameters[$parameterName];

            if ($parameterValue instanceof UrlRoutable) {
                continue;
            }

            $instance = $container->make($parameter->getClass()->name);

            if (! $model = $instance->resolveRouteBinding($parameterValue)) {
                throw (new ModelNotFoundException)->setModel(get_class($instance));
            }

            $route->setParameter($parameterName, $model);
        }
    }
1049281
public function applyFilters(IRoute $route) {
        foreach ($this->getFilters() as $filter) {
            if ($filter->isEnabled()) {
                $invoker = $this->getFilterInvoker();
                $result = $invoker->invoke($filter->getFilter(), $route);

                if (is_bool($result)) {
                    return $result;
                }
            }
        }

        return true;
    }
662296
public function resolveRouteParameters(IRoute $route) {
        $parameters = $route->getParameters();
        $resolvers = $this->getResolvers();
        $invoker = $this->getParameterResolverInvoker();

        foreach ($parameters as $name => $parameter) {
            $resolver = array_get($resolvers, $name);

            if ($resolver instanceof IRouteResolver) {
                $value = $invoker->invoke($resolver->getResolver(), $parameter);

                if ($value === null) {
                    return false;
                }

                $parameters[$name] = $value;
            }
        }

        $route->setParameters($parameters);

        return true;
    }
28148
protected function callChildComponent($component, IContext $context)
    {
        /**
         * @var IRouter $router
         */
        $router = $component->getRouter();
        $router->setBaseUrl($context->getRouteResult()->getMatchedUrl());

        $componentRequest = $this->createComponentRequest($context->getRouteResult()->getUnmatchedUrl());

        try {
            return $component->execute($componentRequest);
        } catch (\Exception $e) {
            return $this->callErrorController($e, $context);
        }
    }
650289
function(route, container) {

    var appName, routeName,
        isService = (container !== this.config.container),
        isError = (route === ERROR_ROUTE_NAME);

    // Normalize Route
    route || (route = '');

    // Get the app name from this route
    appName = routeName = (route.split('/')[0] || 'index');

    // If this isn't the error route, Find Any Custom Route Mappings
    if(!isService && !isError){
      this._currentRoute = route.split('/')[0];
      _.any(this.config.handlers, (handler) => {
        if (handler.regex.test(route)){
          appName = handler.app;
          this._currentRoute = handler.route;
          return true;
        }
      });
    }

    // Wrap these async resource fetches in a promise and return it.
    // This promise resolves when both css and js resources are loaded
    // It rejects if either of the css or js resources fails to load.
    return new Promise((resolve, reject) => {

      var throwError = (err) => {
        // If we are already in an error state, this means we were unable to load
        // a custom error page. Uninstall anything we have and insert our default 404 page.
        if(this.status === ERROR){
          if(isService) return resolve(err);
          this._uninstallResource();
          container.innerHTML = DEFAULT_404_PAGE;
          return resolve(err);
        }

        // Set our status to error and attempt to load a custom error page.
        console.error('Could not ' + ((isService) ? 'load the ' + appName + ' service:' : 'find the ' + (appName || 'index') + ' app.'), 'at', ('/' + route));
        this.status = ERROR;
        this._currentRoute = route;
        resolve(this._fetchResource(ERROR_ROUTE_NAME, container));
      };

      // If the values we got from installing our resources are unexpected, 404
      // Otherwise, set status, activate the css, and install the page component
      var install = (response) => {
        var cssElement = response[0], jsElement = response[1];
        if(!(cssElement instanceof Element) || !(jsElement instanceof Element) ) return throwError();
        (!isService && !isError) && (this.status = SUCCESS);
        cssElement && cssElement.removeAttribute('disabled');
        this._installResource(jsElement.getAttribute('data-name'), appName, container).then(resolve, resolve);
      };

      // If loading a page, set status to loading
      (!isService && !isError) && (this.status = LOADING);

      // If Page Is Already Loaded Then The Route Does Not Exist. 404 and Exit.
      if (this.current && this.current.__pageId === (this.uid + '-' + appName)){ return throwError(); }

      // Fetch our css and js in paralell, install or throw when both complete
      Promise.all([this._fetchCSS(routeName, appName), this._fetchJavascript(routeName, appName)])
      .then(install, throwError);

    });
  }
647630
public static function instance(/** @noinspection PhpUnusedParameterInspection */
        array $routeParams,
        ContainerInterface $container,
        ServerRequestInterface $request
    ): ResponseInterface {
        $params = [
            'post_create_url' => static::createUrl($container, RoleSchema::TYPE, self::METHOD_CREATE),
        ];
        $body   = self::view($container, Views::ROLE_MODIFY_PAGE, $params);

        return new HtmlResponse($body);
    }
1333386
public function findByRoute(string $route): ?PageInterface
    {
        if (!in_array($route, $this->getCmsRoutes(), true)) {
            return null;
        }

        return $this->repository->findOneByRoute($route);
    }
155267
public function bindToRouter(RouterInterface $router)
    {
        $this->callable = sprintf('%s:%s', $this->getActionClass(),
            $this->getActionMethod());

        // TODO Remove and use createCollection() / fetchCollection()
        if ($this->isMakeCollection()) {
            $this->add(new CollectionFetch($this->container, $this));
        }

        $router->addResourceRoute($this);
    }
142728
public static function handle(
        ServerRequestInterface $request,
        Closure $next,
        ContainerInterface $container
    ): ResponseInterface {
        $header = $request->getHeader('Authorization');
        // if value has Bearer token and it is a valid json with 2 required fields and they are strings
        if (empty($header) === false &&
            substr($value = $header[0], 0, 7) === 'Bearer ' &&
            is_string($tokenValue = substr($value, 7)) === true &&
            empty($tokenValue) === false
        ) {
            assert($container->has(PassportAccountManagerInterface::class));

            /** @var PassportAccountManagerInterface $accountManager */
            $accountManager = $container->get(PassportAccountManagerInterface::class);
            try {
                $accountManager->setAccountWithTokenValue($tokenValue);
            } catch (AuthenticationException $exception) {
                if (($logger = static::getLoggerIfEnabled($container)) !== null) {
                    $logger->info(
                        'Passport authentication failed for a given Bearer token value.',
                        ['token' => $tokenValue]
                    );
                }

                return static::createAuthenticationFailedResponse($container);
            }
        } else {
            if (($logger = static::getLoggerIfEnabled($container)) !== null) {
                $logger->debug(
                    'No Bearer token for Passport authentication. The request is not authenticated.'
                );
            }
        }

        // call next middleware handler
        return $next($request);
    }
941323
public function prepandRoutes(IRouter $router, array $routes): void
	{
		if (empty($routes)) {
			return;
		}

		if (!($router instanceof \Traversable) || !($router instanceof \ArrayAccess)) {
			throw new ApiRouteWrongRouterException(sprintf(
				'ApiRoutesResolver can not add ApiRoutes to your router. Use for example %s instead',
				RouteList::class
			));
		}

		$user_routes = $this->findAndDestroyUserRoutes($router);

		/**
		 * Add ApiRoutes first
		 */
		foreach ($routes as $route) {
			$router[] = $route;
		}

		/**
		 * User routes on second place
		 */
		foreach ($user_routes as $route) {
			$router[] = $route;
		}
	}
617549
public function run($handler, IInput $input, IOutput $output, IConsole $console) {
        return $this->container->callMethod($handler, 'run', [
            'input' => $input,
            'in' => $input,
            'output' => $output,
            'out' => $output,
            'console' => $console,
        ]);
    }
766970
public static function execute(ContainerInterface $container, IoInterface $inOut): void
    {
        $action = $inOut->getArgument(static::ARG_ACTION);
        switch ($action) {
            case static::ACTION_CREATE_CACHE:
                (new self())->executeCache($inOut, $container);
                break;
            case static::ACTION_CLEAR_CACHE:
                (new self())->executeClear($inOut, $container);
                break;
            default:
                $inOut->writeError("Unsupported action `$action`." . PHP_EOL);
                break;
        }
    }
1368382
protected function addAction($label, $icon, $route)
    {
        $action = (object)[
            'route' => $route,
            'icon'  => 'fa-' . $icon,
            'text'  => $label,
        ];

        $this->actions->add($action);
    }
53043
public function handle(ServerRequestInterface $request): ResponseInterface
    {
        try {
            $route = $this->matchRoute($request);
        } catch (RouteException $e) {
            throw new RouterException("Invalid route definition", $e->getCode(), $e);
        }

        if (empty($route)) {
            throw new RouteNotFoundException($request->getUri());
        }

        return $this->container->get(ScopeInterface::class)->runScope(
            [RouteInterface::class => $route],
            function () use ($route, $request) {
                return $route->handle($request);
            }
        );
    }
227495
protected function requestHandler(): RequestHandlerInterface
    {
        if (!$this->hasContainer()) {
            throw new RouteException("Unable to configure route pipeline without associated container.");
        }

        if ($this->target instanceof TargetInterface) {
            try {
                return $this->target->getHandler($this->container, $this->matches);
            } catch (TargetException $e) {
                throw new RouteException("Invalid target resolution", $e->getCode(), $e);
            }
        }

        if ($this->target instanceof RequestHandlerInterface) {
            return $this->target;
        }

        try {
            if (is_object($this->target) || is_array($this->target)) {
                $target = $this->target;
            } else {
                $target = $this->container->get($this->target);
            }

            if ($target instanceof RequestHandlerInterface) {
                return $target;
            }

            return new CallableHandler(
                $target,
                $this->container->get(ResponseFactoryInterface::class)
            );
        } catch (ContainerExceptionInterface $e) {
            throw new RouteException($e->getMessage(), $e->getCode(), $e);
        }
    }