Skip to content

[HttpKernel] Move @internal from AbstractSessionListener class to its methods and properties #53057

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -36,13 +36,15 @@
*
* @author Johannes M. Schmitt <schmittjoh@gmail.com>
* @author Tobias Schultze <http://tobion.de>
*
* @internal
*/
abstract class AbstractSessionListener implements EventSubscriberInterface, ResetInterface
{
public const NO_AUTO_CACHE_CONTROL_HEADER = 'Symfony-Session-NoAutoCacheControl';


/**
* @internal
*/
protected $container;
private $sessionUsageStack = [];
private $debug;
Expand All @@ -52,13 +54,19 @@ abstract class AbstractSessionListener implements EventSubscriberInterface, Rese
*/
private $sessionOptions;

/**
* @internal
*/
public function __construct(ContainerInterface $container = null, bool $debug = false, array $sessionOptions = [])
{
$this->container = $container;
$this->debug = $debug;
$this->sessionOptions = $sessionOptions;
}

/**
* @internal
*/
public function onKernelRequest(RequestEvent $event)
{
if (!$event->isMainRequest()) {
Expand Down Expand Up @@ -94,6 +102,9 @@ public function onKernelRequest(RequestEvent $event)
$this->sessionUsageStack[] = $session instanceof Session ? $session->getUsageIndex() : 0;
}

/**
* @internal
*/
public function onKernelResponse(ResponseEvent $event)
{
if (!$event->isMainRequest() || (!$this->container->has('initialized_session') && !$event->getRequest()->hasSession())) {
Expand Down Expand Up @@ -222,13 +233,19 @@ public function onKernelResponse(ResponseEvent $event)
}
}

/**
* @internal
*/
public function onFinishRequest(FinishRequestEvent $event)
{
if ($event->isMainRequest()) {
array_pop($this->sessionUsageStack);
}
}

/**
* @internal
*/
public function onSessionUsage(): void
{
if (!$this->debug) {
Expand Down Expand Up @@ -264,6 +281,9 @@ public function onSessionUsage(): void
throw new UnexpectedSessionUsageException('Session was used while the request was declared stateless.');
}

/**
* @internal
*/
public static function getSubscribedEvents(): array
{
return [
Expand All @@ -274,6 +294,9 @@ public static function getSubscribedEvents(): array
];
}

/**
* @internal
*/
public function reset(): void
{
if (\PHP_SESSION_ACTIVE === session_status()) {
Expand All @@ -291,6 +314,8 @@ public function reset(): void
/**
* Gets the session object.
*
* @internal
*
* @return SessionInterface|null
*/
abstract protected function getSession();
Expand Down