Skip to content

Filtering & sorting#107

Merged
loic425 merged 2 commits into
jolicode:mainfrom
loic425:filtering-and-sorting
May 13, 2026
Merged

Filtering & sorting#107
loic425 merged 2 commits into
jolicode:mainfrom
loic425:filtering-and-sorting

Conversation

@loic425
Copy link
Copy Markdown
Contributor

@loic425 loic425 commented Apr 23, 2026

filtering.mov

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 OriginalStorage listing methods to accept optional in-memory filter/sort callbacks 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

  • $searchValue comes from $criteria as mixed, but it’s passed to strtolower() without casting/validation. If the query is not a string (e.g. malformed request), this will throw a TypeError. Cast to string (or guard with is_scalar) before calling strtolower() / 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),
);
Comment thread src/Bridge/Sylius/src/Admin/Controller/MediaAdminController.php Outdated
loic425 added 2 commits May 13, 2026 11:02
# 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
@loic425 loic425 force-pushed the filtering-and-sorting branch from b1e0a8f to b261950 Compare May 13, 2026 09:11
@loic425 loic425 merged commit 4fb31a1 into jolicode:main May 13, 2026
6 checks passed
@loic425 loic425 deleted the filtering-and-sorting branch May 13, 2026 09:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants