Filtering & sorting#107
Merged
Merged
Conversation
07d8d7e to
b1e0a8f
Compare
damienalexandre
approved these changes
May 13, 2026
There was a problem hiding this comment.
Pull request overview
This PR adds filtering and sorting capabilities to the Sylius admin media explorer, including recursive search behavior and UI adjustments to show full paths when browsing results across subdirectories.
Changes:
- Add Sylius Grid search filter and sortable columns (path, file size) for medias; implement sorting/filtering callbacks in the grid data provider.
- Extend
OriginalStoragelisting methods to accept optional in-memoryfilter/sortcallbacks and pass them through pagination. - Update Sylius admin Twig templates and hooks to render filters and display full paths when search is recursive; add functional tests for filtering/sorting.
Reviewed changes
Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Bridge/Sylius/Admin/Controller/MediaAdminControllerTest.php | Adds functional coverage for filtering and sorting behaviors in the Sylius media explorer. |
| src/Storage/OriginalStorage.php | Adds optional filter/sort callbacks to directory/file/media listings and pagination. |
| src/Bridge/Sylius/templates/admin/media/index/content/body/tabs/content/list_view/data_table/body/directories.html.twig | Displays full directory paths when recursive search is active. |
| src/Bridge/Sylius/templates/admin/media/index/content/body/filters.html.twig | Adds a filters include for the media index page. |
| src/Bridge/Sylius/templates/admin/media/grid/field/path.html.twig | Displays full media paths when recursive search is active. |
| src/Bridge/Sylius/src/Admin/Grid/Provider/MediaGridProvider.php | Implements filtering/sorting callbacks and recursive search behavior for the grid’s media data. |
| src/Bridge/Sylius/src/Admin/Grid/MediaGrid.php | Enables default sorting, adds a search filter, and makes columns sortable. |
| src/Bridge/Sylius/src/Admin/Controller/MediaAdminController.php | Adds sorting/filtering for directory listing and toggles recursive listing during search; removes unused Request param in show(). |
| src/Bridge/Sylius/config/app/twig_hooks/media/index.php | Wires the new filters template into the Sylius twig hooks for the media index. |
Comments suppressed due to low confidence (1)
src/Bridge/Sylius/src/Admin/Grid/Provider/MediaGridProvider.php:72
$searchValuecomes from$criteriaasmixed, but it’s passed tostrtolower()without casting/validation. If the query is not a string (e.g. malformed request), this will throw aTypeError. Cast to string (or guard withis_scalar) before callingstrtolower()/str_contains().
if (!empty($criteria['search']['value'] ?? null)) {
$searchValue = $criteria['search']['value'];
return static fn (Media $media): bool => str_contains(strtolower($media->getPath()), strtolower($searchValue));
}
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+41
to
55
| $criteria = $parameters->get('criteria'); | ||
| $recursive = !empty($criteria['search']['value'] ?? null); | ||
|
|
||
| /** @var array<string, string> $sorting */ | ||
| $sorting = $parameters->get('sorting') ?? $grid->getSorting(); | ||
|
|
||
| try { | ||
| $paginatedMedias = $this->getOriginalStorage()->listMediasPaginated( | ||
| $currentKey, | ||
| recursive: false, | ||
| recursive: $recursive, | ||
| page: $request->query->getInt('page', 1), | ||
| perPage: GridPageResolver::getItemsPerPage($grid, $parameters), | ||
| filter: $this->createFilteringCallback($criteria), | ||
| sort: $this->createSortingCallback($sorting), | ||
| ); |
# Conflicts: # src/Bridge/Sylius/src/Admin/Grid/MediaGrid.php # src/Bridge/Sylius/templates/admin/media/index/content/body/filters.html.twig # src/Bridge/SyliusAdmin/config/app/twig_hooks/media/index.php
b1e0a8f to
b261950
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
filtering.mov