loic425 / sylius-grid-builder
Sylius grid plugin to help building grids
Installs: 1 753
Dependents: 0
Suggesters: 0
Security: 0
Stars: 2
Watchers: 1
Forks: 0
Open Issues: 0
Type:package
Requires
- php: ^7.4 || ^8.0
- sylius/grid-bundle: ^1.9
Requires (Dev)
- lchrusciel/api-test-case: ^5.1
- matthiasnoback/symfony-config-test: ^4.2
- matthiasnoback/symfony-dependency-injection-test: ^4.2
- mobizel/coding-standard: ^1.0
- phpspec/phpspec: ^7.0
- phpstan/phpstan: ^0.12.89
- phpunit/phpunit: ^9.5
- sylius/resource-bundle: ^1.8
- symfony/dotenv: ^5.3
- vimeo/psalm: ^4.7
README
It's now integrated to Sylius grid bundle 1.11 on beta release.
Sylius Grid Builder
Build your Sylius grids in PHP.
<?php // config/sylius/grids/book.php use App\Entity\Author; use App\Entity\Book; use App\Entity\Nationality; use SyliusGridBuilder\Field; use SyliusGridBuilder\Filter; use SyliusGridBuilder\GridBuilder; use SyliusGridBuilder\GridConfig; return static function (GridConfig $grid) { $grid->addGrid(GridBuilder::create('app_book', Book::class) ->addFilter(Filter::create('title', 'string')) ->addFilter(Filter::create('author', 'entity') ->setFormOptions([ 'class' => Author::class, 'multiple' => true, ]) ) ->addFilter(Filter::create('nationality', 'entity') ->setOptions([ 'fields' => ['author.nationality'], ]) ->setFormOptions([ 'class' => Nationality::class, ]) ) ->addFilter(Filter::create('currencyCode', 'string') ->setOptions([ 'fields' => ['price.currencyCode'], ]) ) ->addFilter(Filter::create('state', 'select') ->setFormOptions([ 'multiple' => true, 'choices' => [ 'initial' => 'initial', 'published' => 'published', 'unpublished' => 'unpublished', ], ]) ) ->orderBy('title', 'asc') ->addField(Field::create('title', 'string') ->setLabel('Title') ->setSortable(true) ) ->addField(Field::create('author', 'string') ->setLabel('Author') ->setPath('author.name') ->setSortable(true, 'author.name') ) ->addField(Field::create('nationality', 'string') ->setLabel('Nationality') ->setPath('author.nationality.name') ->setSortable(true, 'author.nationality.name') ) ->setLimits([10, 5, 15]) ->addCreateAction() ->addUpdateAction() ->addDeleteAction() ->addDeleteAction([], 'bulk') ); };
Installation
Install Sylius grid builder with composer.
composer require loic425/sylius-grid-builder
Import your PHP configuration files for your grids.
# config/services.yaml imports: - { resource: "sylius/grids/**.php" }
Documentation
Read the whole Sylius grid bundle documentation to see all the options.
Sylius Grid Bundle documentation
License
Sylius Grid Builder is completely free and released under the MIT License.
Related
Here are some related projects.