Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
alexz707 committed Mar 6, 2024
1 parent 4ca7584 commit 4e0dda4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 21 deletions.
4 changes: 2 additions & 2 deletions src/Filter/AssetExcludeFolderFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

Expand Down
21 changes: 2 additions & 19 deletions src/Filter/AssetPathFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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
);
}
}

0 comments on commit 4e0dda4

Please sign in to comment.