Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 89a0d6e

Browse files
committed
Do not use deprecated Symfony events
1 parent 805fda1 commit 89a0d6e

14 files changed

Lines changed: 42 additions & 43 deletions

File tree

psalm.xml

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,6 @@
8282
<referencedClass name="Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand" />
8383
<referencedClass name="Symfony\Bundle\FrameworkBundle\Controller\Controller" />
8484
<referencedClass name="Symfony\Bundle\FrameworkBundle\Templating\EngineInterface" />
85-
<referencedClass name="Symfony\Component\EventDispatcher\Event" />
86-
<referencedClass name="Symfony\Component\HttpKernel\Event\FilterResponseEvent" />
87-
<referencedClass name="Symfony\Component\HttpKernel\Event\GetResponseEvent" />
88-
<referencedClass name="Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent" />
8985
<referencedClass name="Symfony\Component\Intl\ResourceBundle\CurrencyBundleInterface" />
9086
<referencedClass name="Symfony\Component\Intl\ResourceBundle\LanguageBundleInterface" />
9187
<referencedClass name="Symfony\Component\Intl\ResourceBundle\LocaleBundleInterface" />

src/Sylius/Bundle/AdminBundle/EventListener/ResourceDeleteSubscriber.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use Symfony\Component\HttpFoundation\Request;
2121
use Symfony\Component\HttpFoundation\Session\Flash\FlashBagInterface;
2222
use Symfony\Component\HttpFoundation\Session\SessionInterface;
23-
use Symfony\Component\HttpKernel\Event\GetResponseForExceptionEvent;
23+
use Symfony\Component\HttpKernel\Event\ExceptionEvent;
2424
use Symfony\Component\HttpKernel\KernelEvents;
2525
use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
2626

@@ -48,7 +48,7 @@ public static function getSubscribedEvents(): array
4848
];
4949
}
5050

51-
public function onResourceDelete(GetResponseForExceptionEvent $event): void
51+
public function onResourceDelete(ExceptionEvent $event): void
5252
{
5353
$exception = $event->getException();
5454
if (!$exception instanceof ForeignKeyConstraintViolationException) {

src/Sylius/Bundle/ChannelBundle/Context/FakeChannel/FakeChannelPersister.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
namespace Sylius\Bundle\ChannelBundle\Context\FakeChannel;
1515

1616
use Symfony\Component\HttpFoundation\Cookie;
17-
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
17+
use Symfony\Component\HttpKernel\Event\ResponseEvent;
1818
use Symfony\Component\HttpKernel\HttpKernelInterface;
1919

2020
final class FakeChannelPersister
@@ -27,7 +27,7 @@ public function __construct(FakeChannelCodeProviderInterface $fakeChannelCodePro
2727
$this->fakeChannelCodeProvider = $fakeChannelCodeProvider;
2828
}
2929

30-
public function onKernelResponse(FilterResponseEvent $filterResponseEvent): void
30+
public function onKernelResponse(ResponseEvent $filterResponseEvent): void
3131
{
3232
if (HttpKernelInterface::SUB_REQUEST === $filterResponseEvent->getRequestType()) {
3333
return;

src/Sylius/Bundle/ChannelBundle/spec/Context/FakeChannel/FakeChannelPersisterSpec.php

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use Symfony\Component\HttpFoundation\Request;
2121
use Symfony\Component\HttpFoundation\Response;
2222
use Symfony\Component\HttpFoundation\ResponseHeaderBag;
23-
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
23+
use Symfony\Component\HttpKernel\Event\ResponseEvent;
2424
use Symfony\Component\HttpKernel\HttpKernelInterface;
2525

2626
final class FakeChannelPersisterSpec extends ObjectBehavior
@@ -30,44 +30,44 @@ function let(FakeChannelCodeProviderInterface $fakeHostnameProvider): void
3030
$this->beConstructedWith($fakeHostnameProvider);
3131
}
3232

33-
function it_applies_only_to_master_requests(FilterResponseEvent $filterResponseEvent): void
33+
function it_applies_only_to_master_requests(ResponseEvent $responseEvent): void
3434
{
35-
$filterResponseEvent->getRequestType()->willReturn(HttpKernelInterface::SUB_REQUEST);
35+
$responseEvent->getRequestType()->willReturn(HttpKernelInterface::SUB_REQUEST);
3636

37-
$filterResponseEvent->getRequest()->shouldNotBeCalled();
38-
$filterResponseEvent->getResponse()->shouldNotBeCalled();
37+
$responseEvent->getRequest()->shouldNotBeCalled();
38+
$responseEvent->getResponse()->shouldNotBeCalled();
3939

40-
$this->onKernelResponse($filterResponseEvent);
40+
$this->onKernelResponse($responseEvent);
4141
}
4242

4343
function it_applies_only_for_request_with_fake_channel_code(
4444
FakeChannelCodeProviderInterface $fakeHostnameProvider,
45-
FilterResponseEvent $filterResponseEvent,
45+
ResponseEvent $responseEvent,
4646
Request $request
4747
): void {
48-
$filterResponseEvent->getRequestType()->willReturn(HttpKernelInterface::MASTER_REQUEST);
49-
$filterResponseEvent->getRequest()->willReturn($request);
48+
$responseEvent->getRequestType()->willReturn(HttpKernelInterface::MASTER_REQUEST);
49+
$responseEvent->getRequest()->willReturn($request);
5050

5151
$fakeHostnameProvider->getCode($request)->willReturn(null);
5252

53-
$filterResponseEvent->getResponse()->shouldNotBeCalled();
53+
$responseEvent->getResponse()->shouldNotBeCalled();
5454

55-
$this->onKernelResponse($filterResponseEvent);
55+
$this->onKernelResponse($responseEvent);
5656
}
5757

5858
function it_persists_fake_channel_codes_in_a_cookie(
5959
FakeChannelCodeProviderInterface $fakeHostnameProvider,
60-
FilterResponseEvent $filterResponseEvent,
60+
ResponseEvent $responseEvent,
6161
Request $request,
6262
Response $response,
6363
ResponseHeaderBag $responseHeaderBag
6464
): void {
65-
$filterResponseEvent->getRequestType()->willReturn(HttpKernelInterface::MASTER_REQUEST);
66-
$filterResponseEvent->getRequest()->willReturn($request);
65+
$responseEvent->getRequestType()->willReturn(HttpKernelInterface::MASTER_REQUEST);
66+
$responseEvent->getRequest()->willReturn($request);
6767

6868
$fakeHostnameProvider->getCode($request)->willReturn('fake_channel_code');
6969

70-
$filterResponseEvent->getResponse()->willReturn($response);
70+
$responseEvent->getResponse()->willReturn($response);
7171

7272
$response->headers = $responseHeaderBag;
7373
$responseHeaderBag
@@ -77,6 +77,6 @@ function it_persists_fake_channel_codes_in_a_cookie(
7777
->shouldBeCalled()
7878
;
7979

80-
$this->onKernelResponse($filterResponseEvent);
80+
$this->onKernelResponse($responseEvent);
8181
}
8282
}

src/Sylius/Bundle/CoreBundle/Checkout/CheckoutResolver.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
use Symfony\Component\HttpFoundation\RedirectResponse;
2121
use Symfony\Component\HttpFoundation\Request;
2222
use Symfony\Component\HttpFoundation\RequestMatcherInterface;
23-
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
23+
use Symfony\Component\HttpKernel\Event\RequestEvent;
2424
use Symfony\Component\HttpKernel\KernelEvents;
2525

2626
final class CheckoutResolver implements EventSubscriberInterface
@@ -49,7 +49,7 @@ public function __construct(
4949
$this->stateMachineFactory = $stateMachineFactory;
5050
}
5151

52-
public function onKernelRequest(GetResponseEvent $event): void
52+
public function onKernelRequest(RequestEvent $event): void
5353
{
5454
if (!$event->isMasterRequest()) {
5555
return;

src/Sylius/Bundle/CoreBundle/EventListener/UserCartRecalculationListener.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@
1313

1414
namespace Sylius\Bundle\CoreBundle\EventListener;
1515

16+
use Sylius\Bundle\UserBundle\Event\UserEvent;
1617
use Sylius\Component\Core\Model\OrderInterface;
1718
use Sylius\Component\Order\Context\CartContextInterface;
1819
use Sylius\Component\Order\Context\CartNotFoundException;
1920
use Sylius\Component\Order\Processor\OrderProcessorInterface;
2021
use Symfony\Component\EventDispatcher\Event;
22+
use Symfony\Component\Security\Http\Event\InteractiveLoginEvent;
2123
use Webmozart\Assert\Assert;
2224

2325
final class UserCartRecalculationListener
@@ -35,7 +37,7 @@ public function __construct(CartContextInterface $cartContext, OrderProcessorInt
3537
}
3638

3739
/**
38-
* @throws \InvalidArgumentException
40+
* @param InteractiveLoginEvent|UserEvent $event
3941
*/
4042
public function recalculateCartWhileLogin(Event $event): void
4143
{

src/Sylius/Bundle/LocaleBundle/Listener/RequestLocaleSetter.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Sylius\Component\Locale\Context\LocaleContextInterface;
1717
use Sylius\Component\Locale\Context\LocaleNotFoundException;
1818
use Sylius\Component\Locale\Provider\LocaleProviderInterface;
19-
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
19+
use Symfony\Component\HttpKernel\Event\RequestEvent;
2020

2121
final class RequestLocaleSetter
2222
{
@@ -37,7 +37,7 @@ public function __construct(
3737
/**
3838
* @throws LocaleNotFoundException
3939
*/
40-
public function onKernelRequest(GetResponseEvent $event): void
40+
public function onKernelRequest(RequestEvent $event): void
4141
{
4242
$request = $event->getRequest();
4343

src/Sylius/Bundle/LocaleBundle/spec/Listener/RequestLocaleSetterSpec.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
use Sylius\Component\Locale\Context\LocaleContextInterface;
1818
use Sylius\Component\Locale\Provider\LocaleProviderInterface;
1919
use Symfony\Component\HttpFoundation\Request;
20-
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
20+
use Symfony\Component\HttpKernel\Event\RequestEvent;
2121

2222
final class RequestLocaleSetterSpec extends ObjectBehavior
2323
{
@@ -29,7 +29,7 @@ function let(LocaleContextInterface $localeContext, LocaleProviderInterface $loc
2929
function it_sets_locale_and_default_locale_on_request(
3030
LocaleContextInterface $localeContext,
3131
LocaleProviderInterface $localeProvider,
32-
GetResponseEvent $event,
32+
RequestEvent $event,
3333
Request $request
3434
): void {
3535
$event->getRequest()->willReturn($request);

src/Sylius/Bundle/ShopBundle/EventListener/NonChannelLocaleListener.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
use Sylius\Component\Locale\Provider\LocaleProviderInterface;
1717
use Symfony\Bundle\SecurityBundle\Security\FirewallConfig;
1818
use Symfony\Bundle\SecurityBundle\Security\FirewallMap;
19-
use Symfony\Component\HttpKernel\Event\GetResponseEvent;
19+
use Symfony\Component\HttpKernel\Event\RequestEvent;
2020
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
2121
use Webmozart\Assert\Assert;
2222

@@ -50,7 +50,7 @@ public function __construct(
5050
/**
5151
* @throws NotFoundHttpException
5252
*/
53-
public function restrictRequestLocale(GetResponseEvent $event): void
53+
public function restrictRequestLocale(RequestEvent $event): void
5454
{
5555
if (!$event->isMasterRequest()) {
5656
return;

src/Sylius/Bundle/ShopBundle/EventListener/SessionCartSubscriber.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
use Sylius\Component\Order\Context\CartContextInterface;
1919
use Sylius\Component\Order\Context\CartNotFoundException;
2020
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
21-
use Symfony\Component\HttpKernel\Event\FilterResponseEvent;
21+
use Symfony\Component\HttpKernel\Event\ResponseEvent;
2222
use Symfony\Component\HttpKernel\KernelEvents;
2323
use Webmozart\Assert\Assert;
2424

@@ -46,7 +46,7 @@ public static function getSubscribedEvents(): array
4646
];
4747
}
4848

49-
public function onKernelResponse(FilterResponseEvent $event): void
49+
public function onKernelResponse(ResponseEvent $event): void
5050
{
5151
if (!$event->isMasterRequest()) {
5252
return;

0 commit comments

Comments
 (0)