Skip to content

Commit

Permalink
[HttpKernel] Fix advertizing deprecations for *TestSessionListener
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolas-grekas committed Mar 2, 2022
1 parent 64d15cd commit 06721ab
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 12 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ CHANGELOG
---

* Add the ability to enable the profiler using a request query parameter, body parameter or attribute
* Deprecate `AbstractTestSessionListener::getSession` inject a session in the request instead
* Deprecate `AbstractTestSessionListener` and `TestSessionListener`, use `AbstractSessionListener` and `SessionListener` instead
* Deprecate the `fileLinkFormat` parameter of `DebugHandlersListener`
* Add support for configuring log level, and status code by exception class
* Allow ignoring "kernel.reset" methods that don't exist with "on_invalid" attribute
Expand Down
8 changes: 3 additions & 5 deletions EventListener/AbstractTestSessionListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
use Symfony\Component\HttpKernel\Event\ResponseEvent;
use Symfony\Component\HttpKernel\KernelEvents;

trigger_deprecation('symfony/http-kernel', '5.4', '"%s" is deprecated use "%s" instead.', AbstractTestSessionListener::class, AbstractSessionListener::class);

/**
* TestSessionListener.
*
Expand All @@ -29,7 +31,7 @@
*
* @internal
*
* @deprecated the TestSessionListener use the default SessionListener instead
* @deprecated since Symfony 5.4, use AbstractSessionListener instead
*/
abstract class AbstractTestSessionListener implements EventSubscriberInterface
{
Expand All @@ -39,8 +41,6 @@ abstract class AbstractTestSessionListener implements EventSubscriberInterface
public function __construct(array $sessionOptions = [])
{
$this->sessionOptions = $sessionOptions;

trigger_deprecation('symfony/http-kernel', '5.4', 'The %s is deprecated use the %s instead.', __CLASS__, AbstractSessionListener::class);
}

public function onKernelRequest(RequestEvent $event)
Expand Down Expand Up @@ -114,8 +114,6 @@ public static function getSubscribedEvents(): array
/**
* Gets the session object.
*
* @deprecated since Symfony 5.4, will be removed in 6.0.
*
* @return SessionInterface|null
*/
abstract protected function getSession();
Expand Down
9 changes: 3 additions & 6 deletions EventListener/TestSessionListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,16 @@
use Psr\Container\ContainerInterface;
use Symfony\Component\HttpFoundation\Session\SessionInterface;

trigger_deprecation('symfony/http-kernel', '5.4', '"%s" is deprecated, use "%s" instead.', TestSessionListener::class, SessionListener::class);

/**
* Sets the session in the request.
*
* @author Fabien Potencier <fabien@symfony.com>
*
* @final
*
* @deprecated the TestSessionListener use the default SessionListener instead
* @deprecated since Symfony 5.4, use SessionListener instead
*/
class TestSessionListener extends AbstractTestSessionListener
{
Expand All @@ -33,13 +35,8 @@ public function __construct(ContainerInterface $container, array $sessionOptions
parent::__construct($sessionOptions);
}

/**
* @deprecated since Symfony 5.4, will be removed in 6.0.
*/
protected function getSession(): ?SessionInterface
{
trigger_deprecation('symfony/http-kernel', '5.4', '"%s" is deprecated and will be removed in 6.0, inject a session in the request instead.', __METHOD__);

if ($this->container->has('session')) {
return $this->container->get('session');
}
Expand Down

0 comments on commit 06721ab

Please sign in to comment.