From 36456b679a1e18f69b245c02b72148318d87eb54 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Kukli=C5=84ski?= Date: Mon, 23 Oct 2023 20:39:44 +0200 Subject: [PATCH 01/10] Store new wishlist token on main request --- .../CreateNewWishlistSubscriber.php | 19 ++++++++++++++----- src/Resources/config/services.yml | 1 + 2 files changed, 15 insertions(+), 5 deletions(-) diff --git a/src/EventSubscriber/CreateNewWishlistSubscriber.php b/src/EventSubscriber/CreateNewWishlistSubscriber.php index 2e26ac17..321079a7 100644 --- a/src/EventSubscriber/CreateNewWishlistSubscriber.php +++ b/src/EventSubscriber/CreateNewWishlistSubscriber.php @@ -23,6 +23,7 @@ use Sylius\Component\Core\Model\ShopUserInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\Cookie; +use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\RequestEvent; use Symfony\Component\HttpKernel\Event\ResponseEvent; @@ -47,6 +48,8 @@ final class CreateNewWishlistSubscriber implements EventSubscriberInterface private TokenUserResolverInterface $tokenUserResolver; + private RequestStack $requestStack; + public function __construct( string $wishlistCookieToken, WishlistsResolverInterface $wishlistsResolver, @@ -56,6 +59,7 @@ public function __construct( ChannelContextInterface $channelContext, WishlistCookieTokenResolverInterface $wishlistCookieTokenResolver, TokenUserResolverInterface $tokenUserResolver, + RequestStack $requestStack, ) { $this->wishlistCookieToken = $wishlistCookieToken; $this->wishlistsResolver = $wishlistsResolver; @@ -65,6 +69,7 @@ public function __construct( $this->channelContext = $channelContext; $this->wishlistCookieTokenResolver = $wishlistCookieTokenResolver; $this->tokenUserResolver = $tokenUserResolver; + $this->requestStack = $requestStack; } public static function getSubscribedEvents(): array @@ -81,14 +86,16 @@ public function onKernelRequest(RequestEvent $event): void return; } + $request = $this->requestStack->getMainRequest(); + /** @var WishlistInterface[] $wishlists */ $wishlists = $this->wishlistsResolver->resolve(); - $wishlistCookieToken = $event->getRequest()->cookies->get($this->wishlistCookieToken); + $wishlistCookieToken = $request->cookies->get($this->wishlistCookieToken); if (!empty($wishlists)) { if (null === $wishlistCookieToken) { - $event->getRequest()->attributes->set($this->wishlistCookieToken, reset($wishlists)->getToken()); + $request->attributes->set($this->wishlistCookieToken, reset($wishlists)->getToken()); } return; @@ -99,7 +106,7 @@ public function onKernelRequest(RequestEvent $event): void $wishlistCookieToken = $this->wishlistCookieTokenResolver->resolve(); } - $event->getRequest()->attributes->set($this->wishlistCookieToken, $wishlistCookieToken); + $request->attributes->set($this->wishlistCookieToken, $wishlistCookieToken); } public function onKernelResponse(ResponseEvent $event): void @@ -108,12 +115,14 @@ public function onKernelResponse(ResponseEvent $event): void return; } - if ($event->getRequest()->cookies->has($this->wishlistCookieToken)) { + $request = $this->requestStack->getMainRequest(); + + if ($request->cookies->has($this->wishlistCookieToken)) { return; } $response = $event->getResponse(); - $wishlistCookieToken = $event->getRequest()->attributes->get($this->wishlistCookieToken); + $wishlistCookieToken = $request->attributes->get($this->wishlistCookieToken); if (!$wishlistCookieToken) { return; diff --git a/src/Resources/config/services.yml b/src/Resources/config/services.yml index 5ef8199c..ecac5644 100644 --- a/src/Resources/config/services.yml +++ b/src/Resources/config/services.yml @@ -207,6 +207,7 @@ services: - "@sylius.context.channel" - '@bitbag_sylius_wishlist_plugin.resolver.wishlist_cookie_token_resolver' - '@bitbag_sylius_wishlist_plugin.resolver.token_user_resolver' + - '@request_stack' tags: - { name: kernel.event_subscriber, event: kernel.exception } From 2337aefd05002fb41209312eccd764bdacb530f0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Kukli=C5=84ski?= Date: Mon, 23 Oct 2023 20:48:58 +0200 Subject: [PATCH 02/10] Update WishlistCookieTokenResolver to resolve using request attributes also --- src/Resolver/WishlistCookieTokenResolver.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Resolver/WishlistCookieTokenResolver.php b/src/Resolver/WishlistCookieTokenResolver.php index 4ebe6324..898da80b 100644 --- a/src/Resolver/WishlistCookieTokenResolver.php +++ b/src/Resolver/WishlistCookieTokenResolver.php @@ -32,10 +32,15 @@ public function resolve(): string { $wishlistCookieToken = $this->requestStack->getMainRequest()->cookies->get($this->wishlistCookieToken); - if (!$wishlistCookieToken) { - return (string) new WishlistToken(); + if ($wishlistCookieToken !== null) { + return $wishlistCookieToken; } - return $wishlistCookieToken; + $wishlistCookieToken = $this->requestStack->getMainRequest()->attributes->get($this->wishlistCookieToken); + if ($wishlistCookieToken !== null) { + return $wishlistCookieToken; + } + + return (string) new WishlistToken(); } } From 12dcef46f0bf6ef30cf804a8fc885898a2b3f2e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Kukli=C5=84ski?= Date: Mon, 23 Oct 2023 20:53:06 +0200 Subject: [PATCH 03/10] Remove creating wishlist from Request/Response subscriber --- .../CreateNewWishlistSubscriber.php | 35 ------------------- 1 file changed, 35 deletions(-) diff --git a/src/EventSubscriber/CreateNewWishlistSubscriber.php b/src/EventSubscriber/CreateNewWishlistSubscriber.php index 321079a7..ac451210 100644 --- a/src/EventSubscriber/CreateNewWishlistSubscriber.php +++ b/src/EventSubscriber/CreateNewWishlistSubscriber.php @@ -132,41 +132,6 @@ public function onKernelResponse(ResponseEvent $event): void $event->getRequest()->attributes->remove($this->wishlistCookieToken); } - private function createNewWishlist(?string $wishlistCookieToken): WishlistInterface - { - $token = $this->tokenStorage->getToken(); - $user = $this->tokenUserResolver->resolve($token); - - $wishlist = $this->wishlistFactory->createNew(); - - try { - $channel = $this->channelContext->getChannel(); - } catch (ChannelNotFoundException $exception) { - $channel = null; - } - - if ($channel instanceof ChannelInterface) { - $wishlist->setChannel($channel); - } - - if ($channel instanceof ChannelInterface && - $user instanceof ShopUserInterface - ) { - $wishlist = $this->wishlistFactory->createForUserAndChannel($user, $channel); - } elseif ($user instanceof ShopUserInterface) { - $wishlist = $this->wishlistFactory->createForUser($user); - } - - if ($wishlistCookieToken) { - $wishlist->setToken($wishlistCookieToken); - } - - $wishlist->setName('Wishlist'); - $this->wishlistRepository->add($wishlist); - - return $wishlist; - } - private function setWishlistCookieToken(Response $response, string $wishlistCookieToken): void { $cookie = new Cookie($this->wishlistCookieToken, $wishlistCookieToken, strtotime('+1 year')); From 5264e9b5456ce7b2d76bc0790adf177a8c6492ef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Kukli=C5=84ski?= Date: Mon, 23 Oct 2023 20:54:49 +0200 Subject: [PATCH 04/10] Simplify CreateNewWishlistSubscriber class --- src/EventSubscriber/CreateNewWishlistSubscriber.php | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/EventSubscriber/CreateNewWishlistSubscriber.php b/src/EventSubscriber/CreateNewWishlistSubscriber.php index ac451210..cce41e68 100644 --- a/src/EventSubscriber/CreateNewWishlistSubscriber.php +++ b/src/EventSubscriber/CreateNewWishlistSubscriber.php @@ -101,8 +101,7 @@ public function onKernelRequest(RequestEvent $event): void return; } - if (null === $wishlistCookieToken) - { + if (null === $wishlistCookieToken) { $wishlistCookieToken = $this->wishlistCookieTokenResolver->resolve(); } @@ -116,7 +115,6 @@ public function onKernelResponse(ResponseEvent $event): void } $request = $this->requestStack->getMainRequest(); - if ($request->cookies->has($this->wishlistCookieToken)) { return; } @@ -127,15 +125,10 @@ public function onKernelResponse(ResponseEvent $event): void if (!$wishlistCookieToken) { return; } - $this->setWishlistCookieToken($response, $wishlistCookieToken); - - $event->getRequest()->attributes->remove($this->wishlistCookieToken); - } - private function setWishlistCookieToken(Response $response, string $wishlistCookieToken): void - { $cookie = new Cookie($this->wishlistCookieToken, $wishlistCookieToken, strtotime('+1 year')); - $response->headers->setCookie($cookie); + + $event->getRequest()->attributes->remove($this->wishlistCookieToken); } } From 31d9918de6b5e1c4f59676f3fa820421096d2667 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Kukli=C5=84ski?= Date: Mon, 23 Oct 2023 20:56:27 +0200 Subject: [PATCH 05/10] Tidying CreateNewWishlistSubscriber class --- .../CreateNewWishlistSubscriber.php | 30 ------------------- 1 file changed, 30 deletions(-) diff --git a/src/EventSubscriber/CreateNewWishlistSubscriber.php b/src/EventSubscriber/CreateNewWishlistSubscriber.php index cce41e68..39fe3c79 100644 --- a/src/EventSubscriber/CreateNewWishlistSubscriber.php +++ b/src/EventSubscriber/CreateNewWishlistSubscriber.php @@ -11,24 +11,14 @@ namespace BitBag\SyliusWishlistPlugin\EventSubscriber; use BitBag\SyliusWishlistPlugin\Entity\WishlistInterface; -use BitBag\SyliusWishlistPlugin\Entity\WishlistToken; -use BitBag\SyliusWishlistPlugin\Factory\WishlistFactoryInterface; -use BitBag\SyliusWishlistPlugin\Repository\WishlistRepositoryInterface; -use BitBag\SyliusWishlistPlugin\Resolver\TokenUserResolverInterface; use BitBag\SyliusWishlistPlugin\Resolver\WishlistCookieTokenResolverInterface; use BitBag\SyliusWishlistPlugin\Resolver\WishlistsResolverInterface; -use Sylius\Component\Channel\Context\ChannelContextInterface; -use Sylius\Component\Channel\Context\ChannelNotFoundException; -use Sylius\Component\Core\Model\ChannelInterface; -use Sylius\Component\Core\Model\ShopUserInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\Cookie; use Symfony\Component\HttpFoundation\RequestStack; -use Symfony\Component\HttpFoundation\Response; use Symfony\Component\HttpKernel\Event\RequestEvent; use Symfony\Component\HttpKernel\Event\ResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; -use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface; final class CreateNewWishlistSubscriber implements EventSubscriberInterface { @@ -36,39 +26,19 @@ final class CreateNewWishlistSubscriber implements EventSubscriberInterface private WishlistsResolverInterface $wishlistsResolver; - private WishlistFactoryInterface $wishlistFactory; - - private WishlistRepositoryInterface $wishlistRepository; - - private TokenStorageInterface $tokenStorage; - - private ChannelContextInterface $channelContext; - private WishlistCookieTokenResolverInterface $wishlistCookieTokenResolver; - private TokenUserResolverInterface $tokenUserResolver; - private RequestStack $requestStack; public function __construct( string $wishlistCookieToken, WishlistsResolverInterface $wishlistsResolver, - WishlistFactoryInterface $wishlistFactory, - WishlistRepositoryInterface $wishlistRepository, - TokenStorageInterface $tokenStorage, - ChannelContextInterface $channelContext, WishlistCookieTokenResolverInterface $wishlistCookieTokenResolver, - TokenUserResolverInterface $tokenUserResolver, RequestStack $requestStack, ) { $this->wishlistCookieToken = $wishlistCookieToken; $this->wishlistsResolver = $wishlistsResolver; - $this->wishlistFactory = $wishlistFactory; - $this->wishlistRepository = $wishlistRepository; - $this->tokenStorage = $tokenStorage; - $this->channelContext = $channelContext; $this->wishlistCookieTokenResolver = $wishlistCookieTokenResolver; - $this->tokenUserResolver = $tokenUserResolver; $this->requestStack = $requestStack; } From 5bcb5aa51c9bfc3f67d1cb72d8617ae50882f2a0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Kukli=C5=84ski?= Date: Mon, 23 Oct 2023 21:01:43 +0200 Subject: [PATCH 06/10] Tidying CreateNewWishlistSubscriber service --- src/Resources/config/services.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/Resources/config/services.yml b/src/Resources/config/services.yml index ecac5644..358ac564 100644 --- a/src/Resources/config/services.yml +++ b/src/Resources/config/services.yml @@ -201,12 +201,7 @@ services: arguments: - "%bitbag_sylius_wishlist_plugin.parameters.wishlist_cookie_token%" - "@bitbag_sylius_wishlist_plugin.resolver.wishlists_resolver" - - "@bitbag_sylius_wishlist_plugin.factory.wishlist" - - "@bitbag_sylius_wishlist_plugin.repository.wishlist" - - "@security.token_storage" - - "@sylius.context.channel" - '@bitbag_sylius_wishlist_plugin.resolver.wishlist_cookie_token_resolver' - - '@bitbag_sylius_wishlist_plugin.resolver.token_user_resolver' - '@request_stack' tags: - { name: kernel.event_subscriber, event: kernel.exception } From a579a23a94b13177bd85f87d70fbd40280a00125 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Kukli=C5=84ski?= Date: Mon, 23 Oct 2023 21:34:05 +0200 Subject: [PATCH 07/10] Restrict wishlist cookie creation only for '/wishlist' prefixed URIs --- .../CreateNewWishlistSubscriber.php | 9 ++++++ src/Resolver/WishlistsResolver.php | 29 +++++++------------ 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/EventSubscriber/CreateNewWishlistSubscriber.php b/src/EventSubscriber/CreateNewWishlistSubscriber.php index 39fe3c79..5fc02544 100644 --- a/src/EventSubscriber/CreateNewWishlistSubscriber.php +++ b/src/EventSubscriber/CreateNewWishlistSubscriber.php @@ -57,6 +57,10 @@ public function onKernelRequest(RequestEvent $event): void } $request = $this->requestStack->getMainRequest(); + $currentPath = $request->getPathInfo(); + if (!str_starts_with($currentPath, '/wishlist')) { + return; + } /** @var WishlistInterface[] $wishlists */ $wishlists = $this->wishlistsResolver->resolve(); @@ -85,6 +89,11 @@ public function onKernelResponse(ResponseEvent $event): void } $request = $this->requestStack->getMainRequest(); + $currentPath = $request->getPathInfo(); + if (!str_starts_with($currentPath, '/wishlist')) { + return; + } + if ($request->cookies->has($this->wishlistCookieToken)) { return; } diff --git a/src/Resolver/WishlistsResolver.php b/src/Resolver/WishlistsResolver.php index f54f0951..28729ef0 100644 --- a/src/Resolver/WishlistsResolver.php +++ b/src/Resolver/WishlistsResolver.php @@ -66,7 +66,15 @@ public function resolve(): array $channel = null; } - return $this->getWishlistsByUserOrCookieToken($wishlistCookieToken, $user, $channel); + if ($user instanceof ShopUserInterface) { + return $this->wishlistRepository->findAllByShopUserAndToken($user->getId(), $wishlistCookieToken); + } + + if ($channel instanceof ChannelInterface) { + return $this->wishlistRepository->findAllByAnonymousAndChannel($wishlistCookieToken, $channel); + } + + return $this->wishlistRepository->findAllByAnonymous($wishlistCookieToken); } public function resolveAndCreate(): array @@ -81,8 +89,7 @@ public function resolveAndCreate(): array $channel = null; } - if ([] === $wishlists || null === $wishlists) - { + if (0 === count($wishlists)) { $createWishlist = new CreateWishlist($wishlistCookieToken, $channel?->getCode()); /** @var WishlistInterface $wishlist */ $wishlist = $this->handle($createWishlist); @@ -92,20 +99,4 @@ public function resolveAndCreate(): array return $wishlists; } - - public function getWishlistsByUserOrCookieToken( - string $wishlistCookieToken, - ?UserInterface $user, - ?ChannelInterface $channel - ): ?array { - if ($user instanceof ShopUserInterface) { - return $this->wishlistRepository->findAllByShopUserAndToken($user->getId(), $wishlistCookieToken); - } - - if ($channel instanceof ChannelInterface) { - return $this->wishlistRepository->findAllByAnonymousAndChannel($wishlistCookieToken, $channel); - } - - return $this->wishlistRepository->findAllByAnonymous($wishlistCookieToken); - } } From 73b6f542dc84c7c2905279282c746c7f38fec5b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Kukli=C5=84ski?= Date: Mon, 23 Oct 2023 21:55:39 +0200 Subject: [PATCH 08/10] Small tidying of CreateNewWishlistSubscriber --- src/EventSubscriber/CreateNewWishlistSubscriber.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/EventSubscriber/CreateNewWishlistSubscriber.php b/src/EventSubscriber/CreateNewWishlistSubscriber.php index 5fc02544..2bced5c2 100644 --- a/src/EventSubscriber/CreateNewWishlistSubscriber.php +++ b/src/EventSubscriber/CreateNewWishlistSubscriber.php @@ -93,7 +93,7 @@ public function onKernelResponse(ResponseEvent $event): void if (!str_starts_with($currentPath, '/wishlist')) { return; } - + if ($request->cookies->has($this->wishlistCookieToken)) { return; } @@ -108,6 +108,6 @@ public function onKernelResponse(ResponseEvent $event): void $cookie = new Cookie($this->wishlistCookieToken, $wishlistCookieToken, strtotime('+1 year')); $response->headers->setCookie($cookie); - $event->getRequest()->attributes->remove($this->wishlistCookieToken); + $request->attributes->remove($this->wishlistCookieToken); } } From f2c647c48f87a74a5c7a0d583d2d4c484327f5a4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Kukli=C5=84ski?= Date: Tue, 24 Oct 2023 09:48:51 +0200 Subject: [PATCH 09/10] Review changes --- .../CreateNewWishlistSubscriber.php | 33 +++++++++++-------- src/Resolver/WishlistCookieTokenResolver.php | 4 +-- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/src/EventSubscriber/CreateNewWishlistSubscriber.php b/src/EventSubscriber/CreateNewWishlistSubscriber.php index 2bced5c2..2a2fbd2b 100644 --- a/src/EventSubscriber/CreateNewWishlistSubscriber.php +++ b/src/EventSubscriber/CreateNewWishlistSubscriber.php @@ -15,20 +15,23 @@ use BitBag\SyliusWishlistPlugin\Resolver\WishlistsResolverInterface; use Symfony\Component\EventDispatcher\EventSubscriberInterface; use Symfony\Component\HttpFoundation\Cookie; +use Symfony\Component\HttpFoundation\Request; use Symfony\Component\HttpFoundation\RequestStack; use Symfony\Component\HttpKernel\Event\RequestEvent; use Symfony\Component\HttpKernel\Event\ResponseEvent; use Symfony\Component\HttpKernel\KernelEvents; +use Webmozart\Assert\Assert; final class CreateNewWishlistSubscriber implements EventSubscriberInterface { + private const ALLOWED_ENDPOINTS_PREFIX = '/wishlist'; private string $wishlistCookieToken; private WishlistsResolverInterface $wishlistsResolver; private WishlistCookieTokenResolverInterface $wishlistCookieTokenResolver; - private RequestStack $requestStack; + private Request $mainRequest; public function __construct( string $wishlistCookieToken, @@ -39,7 +42,11 @@ public function __construct( $this->wishlistCookieToken = $wishlistCookieToken; $this->wishlistsResolver = $wishlistsResolver; $this->wishlistCookieTokenResolver = $wishlistCookieTokenResolver; - $this->requestStack = $requestStack; + + $mainRequest = $requestStack->getMainRequest(); + Assert::notNull($mainRequest, 'The class has to be used in HTTP context only'); + + $this->mainRequest = $mainRequest; } public static function getSubscribedEvents(): array @@ -56,20 +63,19 @@ public function onKernelRequest(RequestEvent $event): void return; } - $request = $this->requestStack->getMainRequest(); - $currentPath = $request->getPathInfo(); - if (!str_starts_with($currentPath, '/wishlist')) { + $currentPath = $this->mainRequest->getPathInfo(); + if (!str_starts_with($currentPath, self::ALLOWED_ENDPOINTS_PREFIX)) { return; } /** @var WishlistInterface[] $wishlists */ $wishlists = $this->wishlistsResolver->resolve(); - $wishlistCookieToken = $request->cookies->get($this->wishlistCookieToken); + $wishlistCookieToken = $this->mainRequest->cookies->get($this->wishlistCookieToken); if (!empty($wishlists)) { if (null === $wishlistCookieToken) { - $request->attributes->set($this->wishlistCookieToken, reset($wishlists)->getToken()); + $this->mainRequest->attributes->set($this->wishlistCookieToken, reset($wishlists)->getToken()); } return; @@ -79,7 +85,7 @@ public function onKernelRequest(RequestEvent $event): void $wishlistCookieToken = $this->wishlistCookieTokenResolver->resolve(); } - $request->attributes->set($this->wishlistCookieToken, $wishlistCookieToken); + $this->mainRequest->attributes->set($this->wishlistCookieToken, $wishlistCookieToken); } public function onKernelResponse(ResponseEvent $event): void @@ -88,18 +94,17 @@ public function onKernelResponse(ResponseEvent $event): void return; } - $request = $this->requestStack->getMainRequest(); - $currentPath = $request->getPathInfo(); - if (!str_starts_with($currentPath, '/wishlist')) { + $currentPath = $this->mainRequest->getPathInfo(); + if (!str_starts_with($currentPath, self::ALLOWED_ENDPOINTS_PREFIX)) { return; } - if ($request->cookies->has($this->wishlistCookieToken)) { + if ($this->mainRequest->cookies->has($this->wishlistCookieToken)) { return; } $response = $event->getResponse(); - $wishlistCookieToken = $request->attributes->get($this->wishlistCookieToken); + $wishlistCookieToken = $this->mainRequest->attributes->get($this->wishlistCookieToken); if (!$wishlistCookieToken) { return; @@ -108,6 +113,6 @@ public function onKernelResponse(ResponseEvent $event): void $cookie = new Cookie($this->wishlistCookieToken, $wishlistCookieToken, strtotime('+1 year')); $response->headers->setCookie($cookie); - $request->attributes->remove($this->wishlistCookieToken); + $this->mainRequest->attributes->remove($this->wishlistCookieToken); } } diff --git a/src/Resolver/WishlistCookieTokenResolver.php b/src/Resolver/WishlistCookieTokenResolver.php index 898da80b..ec93ebaf 100644 --- a/src/Resolver/WishlistCookieTokenResolver.php +++ b/src/Resolver/WishlistCookieTokenResolver.php @@ -32,12 +32,12 @@ public function resolve(): string { $wishlistCookieToken = $this->requestStack->getMainRequest()->cookies->get($this->wishlistCookieToken); - if ($wishlistCookieToken !== null) { + if (null !== $wishlistCookieToken) { return $wishlistCookieToken; } $wishlistCookieToken = $this->requestStack->getMainRequest()->attributes->get($this->wishlistCookieToken); - if ($wishlistCookieToken !== null) { + if (null !== $wishlistCookieToken) { return $wishlistCookieToken; } From 97a21f32497ff67d5542a99d5844d27ad4d607d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Marcin=20Kukli=C5=84ski?= Date: Tue, 24 Oct 2023 10:57:14 +0200 Subject: [PATCH 10/10] Code formatting (new line after constant) --- src/EventSubscriber/CreateNewWishlistSubscriber.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/EventSubscriber/CreateNewWishlistSubscriber.php b/src/EventSubscriber/CreateNewWishlistSubscriber.php index 2a2fbd2b..74deb656 100644 --- a/src/EventSubscriber/CreateNewWishlistSubscriber.php +++ b/src/EventSubscriber/CreateNewWishlistSubscriber.php @@ -25,6 +25,7 @@ final class CreateNewWishlistSubscriber implements EventSubscriberInterface { private const ALLOWED_ENDPOINTS_PREFIX = '/wishlist'; + private string $wishlistCookieToken; private WishlistsResolverInterface $wishlistsResolver;