Extract method

This commit is contained in:
Toby Zerner 2015-12-30 15:26:11 +10:30
parent fc168ef675
commit 9786568749

View File

@ -33,9 +33,7 @@ class StartSession implements MiddlewareInterface
$response = $out ? $out($request, $response) : $response;
if ($session->has('csrf_token')) {
$response = $response->withHeader('X-CSRF-Token', $session->get('csrf_token'));
}
$response = $this->withCsrfTokenHeader($response, $session);
return $this->withSessionCookie($response, $session);
}
@ -54,6 +52,15 @@ class StartSession implements MiddlewareInterface
return $session;
}
private function withCsrfTokenHeader(Response $response, SessionInterface $session)
{
if ($session->has('csrf_token')) {
$response = $response->withHeader('X-CSRF-Token', $session->get('csrf_token'));
}
return $response;
}
private function withSessionCookie(Response $response, SessionInterface $session)
{
return FigResponseCookies::set(