From 4e0dda491a2f9e93b93fbfd49b76bbd264784489 Mon Sep 17 00:00:00 2001 From: Alex Zamponi <562324+alexz707@users.noreply.github.com> Date: Wed, 6 Mar 2024 09:08:15 +0100 Subject: [PATCH] Cleanup --- src/Filter/AssetExcludeFolderFilter.php | 4 ++-- src/Filter/AssetPathFilter.php | 21 ++------------------- 2 files changed, 4 insertions(+), 21 deletions(-) diff --git a/src/Filter/AssetExcludeFolderFilter.php b/src/Filter/AssetExcludeFolderFilter.php index 35a27d256..693abbdc0 100644 --- a/src/Filter/AssetExcludeFolderFilter.php +++ b/src/Filter/AssetExcludeFolderFilter.php @@ -35,9 +35,9 @@ public function __construct(AssetQueryProviderInterface $assetQueryProvider) public function apply(Request $request, bool $normalization, array $attributes, array &$context): void { - $excludeFolders = $request->query->get(self::FOLDER_FILTER_QUERY_PARAM); + $excludeFolders = $request->query->getBoolean(self::FOLDER_FILTER_QUERY_PARAM); - if ($excludeFolders !== 'true') { + if (!$excludeFolders) { return; } diff --git a/src/Filter/AssetPathFilter.php b/src/Filter/AssetPathFilter.php index 27e3f84f7..785ab85f9 100644 --- a/src/Filter/AssetPathFilter.php +++ b/src/Filter/AssetPathFilter.php @@ -45,17 +45,8 @@ public function apply(Request $request, bool $normalization, array $attributes, return; } - $includeDescendants = $this->getBooleanValueFromQuery( - $request, - self::AP_INCLUDE_DESCENDANTS_PARAM, - false - ); - - $includeParent = $this->getBooleanValueFromQuery( - $request, - self::AP_INCLUDE_PARENT_PARAM, - false - ); + $includeDescendants = $request->query->getBoolean(self::AP_INCLUDE_DESCENDANTS_PARAM); + $includeParent = $request->query->getBoolean(self::AP_INCLUDE_PARENT_PARAM); $assetQuery = $this->getAssetQuery($context)->filterPath($path, $includeDescendants, $includeParent); $this->setAssetQuery($context, $assetQuery); @@ -96,12 +87,4 @@ public function getDescription(string $resourceClass): array ], ]; } - - private function getBooleanValueFromQuery(Request $request, string $queryName, bool $defaultValue): bool - { - return filter_var( - $request->query->getBoolean($queryName, $defaultValue), - FILTER_VALIDATE_BOOLEAN - ); - } }