From ccf70ef98b2790c33540bf84fccde8d9d451db9e Mon Sep 17 00:00:00 2001 From: Stefan Hagspiel Date: Thu, 30 May 2024 21:00:19 +0200 Subject: [PATCH] clean up --- .../Type/PimcoreExportDataAwareModifier.php | 21 ++++++++++--------- .../PimcoreInlineRendererAwareModifier.php | 4 ++++ 2 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/I18nBundle/Modifier/RouteItem/Type/PimcoreExportDataAwareModifier.php b/src/I18nBundle/Modifier/RouteItem/Type/PimcoreExportDataAwareModifier.php index 1686fe9..ed662d3 100644 --- a/src/I18nBundle/Modifier/RouteItem/Type/PimcoreExportDataAwareModifier.php +++ b/src/I18nBundle/Modifier/RouteItem/Type/PimcoreExportDataAwareModifier.php @@ -22,20 +22,12 @@ public function __construct(protected RequestStack $requestStack) public function supportParameters(string $type, RouteItemInterface $routeItem, array $parameters, array $context): bool { - if (!$this->requestStack->getMainRequest() instanceof Request) { - return false; - } - - return in_array($this->requestStack->getMainRequest()->attributes->get('_route'), self::EXPORT_AWARE_ROUTES, true); + return $this->isValidRequest(); } public function supportRequest(string $type, RouteItemInterface $routeItem, Request $request, array $context): bool { - if (!$this->requestStack->getMainRequest() instanceof Request) { - return false; - } - - return in_array($this->requestStack->getMainRequest()->attributes->get('_route'), self::EXPORT_AWARE_ROUTES, true); + return $this->isValidRequest(); } public function modifyByParameters(RouteItemInterface $routeItem, array $parameters, array $context): void @@ -90,4 +82,13 @@ protected function modify(RouteItemInterface $routeItem, Request $request): void $routeItem->getRouteParametersBag()->set('_locale', $element->getProperty('language')); } } + + private function isValidRequest(): bool + { + if (!$this->requestStack->getMainRequest() instanceof Request) { + return false; + } + + return in_array($this->requestStack->getMainRequest()->attributes->get('_route'), self::EXPORT_AWARE_ROUTES, true); + } } diff --git a/src/I18nBundle/Modifier/RouteItem/Type/PimcoreInlineRendererAwareModifier.php b/src/I18nBundle/Modifier/RouteItem/Type/PimcoreInlineRendererAwareModifier.php index 6a011eb..c470ffc 100644 --- a/src/I18nBundle/Modifier/RouteItem/Type/PimcoreInlineRendererAwareModifier.php +++ b/src/I18nBundle/Modifier/RouteItem/Type/PimcoreInlineRendererAwareModifier.php @@ -85,6 +85,10 @@ private function determinateDocumentByRoute(Request $request): ?Document private function isValidRequest(): bool { + if (!$this->requestStack->getMainRequest() instanceof Request) { + return false; + } + return in_array( $this->requestStack->getMainRequest()->attributes->get('_route'), self::EDIT_AWARE_ROUTES,