Build the session instance.

@param  \SessionHandlerInterface  $handler
@return \Illuminate\Session\Store
166836
protected function buildSession($handler)
	{
		if ($this->app['config']['session.encrypt'])
		{
			return new EncryptedStore(
				$this->app['config']['session.cookie'], $handler, $this->app['encrypter']
			);
		}
		else
		{
			return new Store($this->app['config']['session.cookie'], $handler);
		}
	}
534828
public function handler($handler = null)
    {
        if ($handler !== null) {
            $this->handler = $this->getRealHandler($handler);
        }

        return $this->handler;
    }
656888
public function create(callable $handler): callable
    {
        foreach ($this->wrappers as $wrapper) {
            $handler = $wrapper->wrap($handler);
        }

        return $handler;
    }
137550
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $response = $handler->handle($request);

        return $this->withStaticHeaders($response, $this->headers);
    }
1260470
private static function createMiddlewareFromClosure(Closure $handler): MiddlewareInterface
    {
        return new class($handler) implements MiddlewareInterface {
            private $handler;

            public function __construct(Closure $handler)
            {
                $this->handler = $handler;
            }

            public function process(ServerRequestInterface $request, RequestHandlerInterface $next): ResponseInterface
            {
                return call_user_func($this->handler, $request, $next);
            }
        };
    }
465112
public function setHandler(string $handlerId, HandlerInterface $handler): self
    {
        $this->_handlers[$handlerId] = $handler;

        return $this;
    }
798118
public function use_default_handler( HandlerInterface $handler = NULL ) {

		static $done = FALSE;
		if ( $done ) {
			return $this;
		}

		$done = TRUE;

		add_action(
			HandlersRegistry::ACTION_REGISTER,
			function ( HandlersRegistry $registry ) use ( $handler ) {

				$handler = DefaultHandlerFactory::with_default_handler( $handler )
					->create_default_handler();

				$registry->add_handler( $handler, HandlersRegistry::DEFAULT_NAME );
			},
			1
		);

		return $this;
	}
577994
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        // TODO : lever une exception si la session est déjà démarrée, cela évitera de faire un "if isStarted" dans la méthode $this->startSession()
        $sessionManager = new SessionManager($request->getCookieParams());

        if (! $sessionManager->isStarted()) {
            $this->configAndStartSession($sessionManager);
        }

        $request = $request->withAttribute(SessionManager::class, $sessionManager);

        return $handler->handle($request);
    }
788242
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        // Bind the request into the container
        app()->instance(ServerRequestInterface::class, $request);

        // Load the route and routing table.
        $route  = $request->getQueryParams()['route'] ?? '';
        $routes = require 'routes/web.php';

        // Find the routing for the selected route.
        $routing = $routes[$request->getMethod() . ':' . $route] ?? '';

        // This timer gets stopped automatically when we generate the response.
        DebugBar::startMeasure('controller_action');

        // No route matched?
        if ($routing === '') {
            return $handler->handle($request);
        }

        // Routes defined using controller@action
        if (Str::contains($routing, '@')) {
            [$class, $method] = explode('@', $routing);

            $controller = app(self::CONTROLLER_NAMESPACE . $class);

            return app()->dispatch($controller, $method);
        }

        // Routes defined using a request handler
        return app($routing)->handle($request);
    }
739986
public function handle($handler = null, array $params = null): ResponseInterface
    {
        $handler = $this->handler($handler);
        $params = $this->params($params);

        $parameters = null;
        if (!$handler instanceof \Closure) {
            [$class, $method] = $this->convert($handler);

            if ($method === null) {
                $key = $handler = $class;
            } else {
                $controller = new $class;
                $handler = [$controller, $method];
                $key = "{$class}::{$method}";
            }

            $parameters = self::optimizeGet($key);
            if ($parameters === false) {
                $parameters = Builder::getCallableParameters($handler, true);
                self::optimizeSet($key, $parameters);
            }
        }

        $result = $this->container->call($handler, $params, $parameters);

        if ($result instanceof ResponseInterface) {
            return $result;
        }

        /** @var Response $response */
        $response = $this->get('response');

        return $response->default($result);
    }
1154817
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        if (!$this->isValid($request)) {
            return $this->createResponse(403);
        }

        return $handler->handle($request);
    }
1139404
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $method = $this->getOverrideMethod($request);

        if (!empty($method) && $method !== $request->getMethod()) {
            $allowed = $this->getAllowedOverrideMethods($request);

            if (!empty($allowed)) {
                if (in_array($method, $allowed)) {
                    $request = $request->withMethod($method);
                } else {
                    return $this->createResponse(405);
                }
            }
        }

        return $handler->handle($request);
    }
346881
public function createHandlerByConfig(): \SessionHandlerInterface
    {
        if (!isset($this->getConfig()['driver'])) {
            throw new \InvalidArgumentException('Session driver required');
        }
        $handler = $this->getHandler($this->getConfig()['driver']);
        $handler instanceof LifetimeInterface && $handler->setLifetime($this->getConfig()['lifetime']);
        return $handler;
    }
1037646
protected function setHandler(ServerRequestInterface $request, $handler): ServerRequestInterface
    {
        return $request->withAttribute($this->attribute, $handler);
    }
887424
public static function newProxyInstance(string $className, HandlerInterface $handler)
    {
        $reflectionClass = new \ReflectionClass($className);
        $reflectionMethods = $reflectionClass->getMethods(\ReflectionMethod::IS_PUBLIC | \ReflectionMethod::IS_PROTECTED);

        // Proxy property
        $id = \uniqid('', false);
        $proxyClassName = \basename(str_replace("\\", '/', $className));
        $proxyClassName = $proxyClassName . '_' . $id;
        $handlerPropertyName = '__handler_' . $id;

        // Base class template
        $template = "class $proxyClassName extends $className {
            private \$$handlerPropertyName;
            public function __construct(\$handler)
            {
                \$this->{$handlerPropertyName} = \$handler;
            }
        ";

        // Methods
        $template .= self::getMethodsTemplate($reflectionMethods, $handlerPropertyName);
        $template .= '}';

        eval($template);
        $newRc = new \ReflectionClass($proxyClassName);

        return $newRc->newInstance($handler);
    }
810836
private function initHandler(SaveHandlerInterface $handler)
    {
        return session_set_save_handler(array($handler, 'open'), 
                                        array($handler, 'close'), 
                                        array($handler, 'read'), 
                                        array($handler, 'write'), 
                                        array($handler, 'destroy'), 
                                        array($handler, 'gc'));
    }
239629
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        $context = RequestBootstrap::getInternalRequestContext();
        if (empty($context) || empty($context->getFrontendUserId())) {
            return $handler->handle($request);
        }

        $GLOBALS['TSFE']->fe_user->checkPid = 0;

        $frontendUser = GeneralUtility::makeInstance(ConnectionPool::class)
            ->getConnectionForTable('fe_users')
            ->select(['*'], 'fe_users', ['uid' => $context->getFrontendUserId()])
            ->fetch();
        if (is_array($frontendUser)) {
            $GLOBALS['TSFE']->fe_user->createUserSession($frontendUser);
            $GLOBALS['TSFE']->fe_user->user = $GLOBALS['TSFE']->fe_user->fetchUserSession();
            $GLOBALS['TSFE']->initUserGroups();
            $this->setFrontendUserAspect(GeneralUtility::makeInstance(Context::class), $GLOBALS['TSFE']->fe_user);
        }

        return $handler->handle($request);
    }