presta / sonata-saved-filters-bundle
A Symfony bundle to allow user to save and share filters in Sonata Admin
Installs: 1 552
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 9
Forks: 0
Open Issues: 0
Requires
- php: ^8.1
- doctrine/orm: ^2.7|^3.2
- sonata-project/admin-bundle: ^4.22
- sonata-project/doctrine-orm-admin-bundle: ^4.9
- symfony/framework-bundle: ^6.3|^7.0
- symfony/validator: ^6.3|^7.0
- twig/twig: ^3.5
Requires (Dev)
- phpstan/phpstan: ^1.10
- phpunit/phpunit: ^9.5
- symfony/browser-kit: ^6.3|^7.0
- symfony/css-selector: ^6.3|^7.0
- symplify/easy-coding-standard: ^11.3
This package is auto-updated.
Last update: 2024-12-01 00:08:24 UTC
README
PrestaSonataSavedFiltersBundle will allow your Sonata users to save and share list filters.
Preview
On each admin, you can save current filters to a dedicated database entry, after naming it.
When you saved a filter, you can reapply it whenever you want on the admin it was created.
An admin exists where you can see, share, remove filters created in the application.
Installation
Install the bundle with the command:
$ composer require presta/sonata-saved-filters-bundle
Enable the bundle:
# config/bundles.php return [ + Presta\SonataSavedFiltersBundle\PrestaSonataSavedFiltersBundle::class => ['all' => true], ];
Configuration
Import our Javascripts in your project:
import '../../public/bundles/prestasonatasavedfilters/scripts/app';
This step is highly dependent on how your public assets are built, imported. It's up to you knowing the best way to include it in your project.
Include our action template into the Twig template you configured to be your admin layout:
{% extends '@SonataAdmin/standard_layout.html.twig' %} {% block sonata_admin_content_actions_wrappers %} {{ parent() }} {{ include('@PrestaSonataSavedFilters/saved_filters_action.html.twig') }} {% endblock %}
See related SonataAdmin documentation
Configure to doctrine that what entity will be attached to saved filters config/packages/doctrine.yaml
:
<?php use Doctrine\ORM\Mapping as ORM; use Presta\SonataSavedFiltersBundle\Entity\SavedFiltersOwnerInterface; use Symfony\Component\Security\Core\User\UserInterface; #[ORM\Entity] class User implements UserInterface, SavedFiltersOwnerInterface { }
# config/packages/doctrine.yaml doctrine: orm: resolve_target_entities: Presta\SonataSavedFiltersBundle\Entity\SavedFiltersOwnerInterface: 'App\Entity\User'
See related DoctrineBundle documentation
Add the admin to the menu, where you want it:
# config/packages/sonata_admin.yaml sonata_admin: dashboard: groups: the_group_in_which_you_want_the_admin: items: - presta_sonata_saved_filters.saved_filters
Finally, update your schema to create the tables required for our entities:
$ bin/console doctrine:schema:update
Or create a migration if you have
DoctrineMigrationsBundle
installed:$ bin/console doctrine:migrations:diff $ bin/console doctrine:migrations:migrate
This project is supported by PrestaConcept
Released under the MIT License