Start the middleware running process

@param Request $request
@param array $args
@return mixed
344997
public function process(Request $request, ...$args)
    {
        if (!isset($this->middlewares[$this->index]) || empty($this->middlewares)) {
            return Dispatcher::PIPE_EMPTY;
        }

        $middleware = $this->middlewares[$this->index];

        $this->index++;

        $params = $args;

        if (is_array($middleware)) {
            if (isset($middleware['params'])) {
                $params = array_merge($args, $middleware['params']);
            }

            if (isset($middleware['class'])) {
                $middleware = [new $middleware['class'], 'process'];
            }
        }

        $params = [$request, [$this, 'process'], $params];

        return call_user_func_array(
            $middleware,
            $params
        );
    }
171131
protected function startSession(Request $request)
    {
        $this->gc();
        $this->session->setId($request->getCookies()->get($this->session->getName()));
        $this->sessionHandler->open(null, $this->session->getName());
        $sessionVars = @unserialize($this->sessionHandler->read($this->session->getId()));

        if ($sessionVars === false) {
            $sessionVars = [];
        }

        $this->session->start($sessionVars);
    }
604417
public function run(ServerRequestInterface $request): void
    {
        $this->emitter->emit(
            $this->middleware->handle($request)
        );
    }
4606
public function process(ServerRequestInterface $request): ResponseInterface
    {
        /** @var Middleware $middleware */
        $middleware = current($this->middlewares);
        next($this->middlewares);

        // return $middleware->process($request, $this);
        try {
            $response = $middleware->process($request, $this);
        } catch (Throwable $error) {
            // next lines
        }
        if (!isset($response)) {
            $response = App::response();
        }

        if (isset($error) && $response instanceof Response) {
            $response->setError($error);
        }
        return $response;
    }
211225
public function run(Request $request) {
    // process the requested action
    ObjectFactory::getInstance('actionMapper')->processAction($request, $this->response);
    return $this->response;
  }
784580
public function process(RequestInterface $request)
    {
        if ($this->processingStack !== null) {
            throw new \RuntimeException('Middleware stack is already processing.');
        }
        if (!count($this->middlewares)) {
            throw new \RuntimeException('Middleware stack is empty.');
        }
        if (!($request instanceof ServerRequestInterface)) {
            throw new \InvalidArgumentException('ServerRequest request expected.');
        }
        $this->processingStack = array_reverse($this->middlewares);
        /** @var ServerMiddlewareInterface $middleware */
        $middleware = array_shift($this->processingStack);
        return $middleware->process($request, $this);
    }
437413
public function handle(ServerRequestInterface $request): ResponseInterface
    {
        $middleware = array_shift($this->middleware);

        // Use default callable if there is no middleware.
        if ($middleware === null) {
            return \call_user_func($this->handler, $request);
        }

        if ($middleware instanceof MiddlewareInterface) {
            return $middleware->process($request, clone $this);
        }

        if (null === $this->container || !$this->container->has($middleware)) {
            throw new InvalidArgumentException(
                sprintf('The middleware is not a valid %s and is not passed in the Container', MiddlewareInterface::class),
                $middleware
            );
        }

        array_unshift($this->middleware, $this->container->get($middleware));

        return $this->handle($request);
    }
142418
public function startAction(Request $request)
    {
        $data = json_decode($request->getContent(), true);

        $publicFile = $this->om->getObject($data['file'], PublicFile::class) ?? new PublicFile();

        $this->container->get('claroline.manager.api_manager')->import(
            $publicFile,
            $data['action'],
            $this->getLogFile($request)
        );

        //the following line doesn't work on our live server but it's supposed to be the proper way to do it
        //$this->async->run('claroline:api:load '.$publicFile->getId().' '.$data['action'].' '.$this->getLogFile($request));

        return new JsonResponse('started', 200);
    }
400382
public function process(Request $request, callable $next)
    {
        if (Auth::check()) {
            return $next($request);
        }

        return redirect($this->redirectTo());
    }
923584
public function create(Request $request, Response $response, array $args)
    {
        $validator = $this->createValidator();

        $rawData = $request->request->all();

        $result = $validator->run($rawData);

        if ($result->isValid()) {
            $fields = $result->getValidated();
            $data = array_intersect_key($rawData, array_flip($fields));

            $entity = $this->createEntity($data);

            $this->em->persist($entity);
            $this->em->flush();

            return new RedirectResponse($request->getUri());
        }

        $request->attributes->set('repopulate', true);

        $response = $this->createAction($request, $response, $args);

        return $response;
    }
134446
public static function run(string $args) : SymfonyProcess
  {
    $process = new SymfonyProcess('php ' . Accessor::$appRoot . 'craftsman ' . $args);
    $process->run();

    return $process;
  }
22190
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $middlewares = $this->module_service->findByInterface(MiddlewareInterface::class);

        $pipeline = $handler;

        foreach ($middlewares as $middleware) {
            $pipeline = new class($pipeline, $middleware) implements RequestHandlerInterface {
                /** @var RequestHandlerInterface */
                private $handler;

                /** @var MiddlewareInterface */
                private $middleware;

                public function __construct(RequestHandlerInterface $handler, MiddlewareInterface $middleware)
                {
                    $this->handler    = $handler;
                    $this->middleware = $middleware;
                }

                public function handle(ServerRequestInterface $request): ResponseInterface
                {
                    return $this->middleware->process($request, $this->handler);
                }
            };
        }

        return $pipeline->handle($request);
    }
148495
protected function run($method, $args) {
		$request = $this->request();
		$request->method($method);
		$request->resource(array_shift($args));
		if (count($args)) {
			$request->params(array_shift($args));
		}
		if (count($args)) {
			$request->files(array_shift($args));
		}
		return $request->send();
	}
121834
final public function run(Request $request)
    {
        $this->request = $request;
        $path = $this->request->getUri()->getPath();
        $this->requestedUri = ($path != "/") ? rtrim($path, "/") : "/";
        $this->requestedMethod = strtoupper($this->request->getMethod());
        $this->requestedRepresentation = $this->request->getAccept();
        $this->verifyRequestMethod();
        $route = $this->findRouteFromRequest();
        $this->prepareResponse($route);
    }
1059812
public function run(Request $request)
	{
		$this->container = $this->container ?: new Container;

		try
		{
			if ( ! is_string($this->action['uses']))
			{
				return $this->runCallable($request);
			}

			if ($this->customDispatcherIsBound())
			{
				return $this->runWithCustomDispatcher($request);
			}

			return $this->runController($request);
		}
		catch (HttpResponseException $e)
		{
			return $e->getResponse();
		}
	}
121580
public function dispatch(Request $request)
    {
        $url = $request->getQueryString();
        $url = $this->RemoveQueryString($url, new Request());
        if ($this->match($url)) {
            (isset($this->params['middleware'])) ? $this->params['middleware'] = new $this->params['middleware']() : null;
            if (!isset($this->params['callable'])) {
                $controller = $this->params['controller'];
                $controller = $this->convertToStudlyCaps($controller);
                $controller = $this->getNamespace().$controller;
                if (class_exists($controller)) {
                    (isset($this->params['middleware']) && is_object($this->params['middleware'])) ? ( new $this->params['middleware']())->before(new Request(), new Response(), $this->params) : null;
                    $controller_object = new $controller($this->params, $this->getInput(new Input()));
                    $action = $this->params['action'];
                    $action = $this->convertToCamelCase($action);
                    if (preg_match('/action$/i', $action) == 0) {
                        $controller_object->$action();
                        (isset($this->params['middleware']) && is_object($this->params['middleware'])) ? (new $this->params['middleware']())->after(new Request(), new Response(), $this->params) : null;
                    } else {
                        throw new \Exception("Method $action in controller $controller cannot be called directly - remove the Action suffix to call this method");
                    }
                } else {
                    throw new \Exception("Controller class $controller not found");
                }
            } else {
                (is_object(isset($this->params['middleware']))) ? $this->params['middleware']->before(new Request(), new Response(), $this->params) : null;
                call_user_func($this->params['callable'], $this->params);
                (is_object(isset($this->params['middleware']))) ? $this->params['middleware']->after(new Request(), new Response(), $this->params) : null;
            }
        } else {
            View::view('errors/404', [], true, [], 404);
        }
    }
945405
public function execute(Request $request)
    {

        $phases = ['prepare', 'respond', 'close'];
        $response = null;

        foreach ($phases as $phase) {

            $key = 0;

            if ($phase === 'respond' && is_null($response)) {
                throw new StackException;
            } else if ($phase === 'close' && $key === 0) {
                $response->send();
            }

            if ($phase === 'prepare' && count($this->{$phase . 'ableMiddlewares'}) === 0) {
                throw new StackException('You must at least add one prepareableMiddleware that generates a Response.');
            } else if (count($this->{$phase . 'ableMiddlewares'}) === 0) {
                continue;
            }

            $next_middleware_spec = $this->{$phase . 'ableMiddlewares'}[$key];

            //Use a while so that middlewares can add other middlewares to execute
            while ($next_middleware_spec) {
                //Get the middleware
                $middleware = array_shift($next_middleware_spec);

                if (!is_null($response)) {
                    array_unshift($next_middleware_spec, $response);
                }

                //Put request as first parameter for the middleware
                array_unshift($next_middleware_spec, $request);

                $return = call_user_func_array([$middleware, $phase], $next_middleware_spec);

                if ($phase === 'prepare' && $return instanceof Response) {
                    $response = $return;
                    break;
                } else if ($phase === 'respond') {
                    //Reassign response in case it was recreated during that phase
                    $response = $return;
                }
                $key++;
                $next_middleware_spec = isset($this->{$phase . 'ableMiddlewares'}[$key]) ? $this->{$phase . 'ableMiddlewares'}[$key] : false;
            }
        }
    }