Skip to content

Commit

Permalink
clean up
Browse files Browse the repository at this point in the history
  • Loading branch information
solverat committed May 30, 2024
1 parent bc10e83 commit ccf70ef
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit ccf70ef

Please sign in to comment.