From 88ecb7e9d6d1c223d924610d42840b948695afef Mon Sep 17 00:00:00 2001 From: Svyatoslav Varpikhovsky Date: Tue, 24 Jan 2023 18:01:46 +0200 Subject: [PATCH] FRW-19 Support Symfony packages v6. (#9610) FRW-19 Support Symfony v6 --- phpstan.neon | 5 +++++ .../Monitoring/Plugin/ControllerListener.php | 16 +++++++++++++++- .../Communication/Plugin/ControllerListener.php | 16 +++++++++++++++- 3 files changed, 35 insertions(+), 2 deletions(-) diff --git a/phpstan.neon b/phpstan.neon index 89ad65e..264cfc5 100644 --- a/phpstan.neon +++ b/phpstan.neon @@ -1,3 +1,8 @@ parameters: level: 7 checkMissingIterableValueType: false + reportUnmatchedIgnoredErrors: false + ignoreErrors: + - '#^Call to function method_exists\(\) with Symfony\\Component\\HttpKernel\\Event\\ControllerEvent and#' + - '#Call to an undefined method Symfony\\Component\\HttpKernel\\Event\\ControllerEvent\:\:isMainRequest\(\).#' + diff --git a/src/Spryker/Yves/Monitoring/Plugin/ControllerListener.php b/src/Spryker/Yves/Monitoring/Plugin/ControllerListener.php index 2baafc2..214f36c 100644 --- a/src/Spryker/Yves/Monitoring/Plugin/ControllerListener.php +++ b/src/Spryker/Yves/Monitoring/Plugin/ControllerListener.php @@ -58,7 +58,7 @@ public function __construct( */ public function onKernelController(ControllerEvent $event): void { - if (!$event->isMasterRequest()) { + if (!$this->isMainRequest($event)) { return; } @@ -101,4 +101,18 @@ public static function getSubscribedEvents(): array KernelEvents::CONTROLLER => ['onKernelController', static::PRIORITY], ]; } + + /** + * @param \Symfony\Component\HttpKernel\Event\ControllerEvent $event + * + * @return bool + */ + protected function isMainRequest(ControllerEvent $event): bool + { + if (method_exists($event, 'isMasterRequest')) { + return $event->isMasterRequest(); + } + + return $event->isMainRequest(); + } } diff --git a/src/Spryker/Zed/Monitoring/Communication/Plugin/ControllerListener.php b/src/Spryker/Zed/Monitoring/Communication/Plugin/ControllerListener.php index efacfa9..97f73ea 100644 --- a/src/Spryker/Zed/Monitoring/Communication/Plugin/ControllerListener.php +++ b/src/Spryker/Zed/Monitoring/Communication/Plugin/ControllerListener.php @@ -79,7 +79,7 @@ public function __construct( */ public function onKernelController(ControllerEvent $event): void { - if (!$event->isMasterRequest()) { + if (!$this->isMainRequest($event)) { return; } @@ -152,4 +152,18 @@ protected function addStore(): void $this->monitoringService->addCustomParameter('store', $this->storeFacade->getCurrentStore()->getName()); } } + + /** + * @param \Symfony\Component\HttpKernel\Event\ControllerEvent $event + * + * @return bool + */ + protected function isMainRequest(ControllerEvent $event): bool + { + if (method_exists($event, 'isMasterRequest')) { + return $event->isMasterRequest(); + } + + return $event->isMainRequest(); + } }