コード例 #1
0
 /**
  * {@inheritDoc}
  */
 protected function setUp()
 {
     $this->wrappedSession = $this->getMock(SessionInterface::class);
     $this->sessionLoader = $this->getMock(\stdClass::class, ['__invoke']);
     $this->lazySession = LazySession::fromContainerBuildingCallback($this->sessionLoader);
 }
コード例 #2
0
 /**
  * {@inheritdoc}
  *
  * @throws \InvalidArgumentException
  * @throws \OutOfBoundsException
  */
 public function __invoke(Request $request, Response $response, callable $out = null) : Response
 {
     $token = $this->parseToken($request);
     $sessionContainer = LazySession::fromContainerBuildingCallback(function () use($token) : SessionInterface {
         return $this->extractSessionContainer($token);
     });
     if (null !== $out) {
         $response = $out($request->withAttribute(self::SESSION_ATTRIBUTE, $sessionContainer), $response);
     }
     return $this->appendToken($sessionContainer, $response, $token);
 }