Skip to content

Commit

Permalink
add filter
Browse files Browse the repository at this point in the history
  • Loading branch information
vasilvestre committed Oct 22, 2024
1 parent 1b1580f commit 4ad598f
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/Bundle/Grid/AbstractGrid.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ public static function getName(): string
return $attribute[0]->newInstance()->name;
}

return static::getName();
return static::class;
}

public function getResourceClass(): string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
use Sylius\Bundle\GridBundle\Builder\GridBuilder;
use Sylius\Bundle\GridBundle\DependencyInjection\SyliusGridExtension;
use Sylius\Bundle\GridBundle\Doctrine\ORM\Driver;
use Sylius\Component\Grid\Tests\Dummy\AttributeFooGrid;
use Sylius\Component\Grid\Tests\Dummy\ClassAsParameterGrid;
use Sylius\Component\Grid\Tests\Dummy\Foo;
use Sylius\Component\Grid\Tests\Dummy\FooFightersGrid;
Expand Down Expand Up @@ -903,6 +904,37 @@ public function it_builds_extended_grids_with_grids_as_service(): void
]);
}

/**
* @test
*/
public function it_builds_grid_with_a_grid_attribute(): void
{
$grid = new AttributeFooGrid();

$this->load([
'grids' => [
'app_foo_with_attribute' => $grid->toArray(),
],
]);

$this->assertContainerBuilderHasParameter('sylius.grids_definitions', [
'app_foo_with_attribute' => [
'driver' => [
'name' => Driver::NAME,
'options' => [
'class' => Foo::class,
],
],
'removals' => [],
'sorting' => [],
'limits' => [10, 25, 50],
'fields' => [],
'filters' => [],
'actions' => [],
],
]);
}

protected function getContainerExtensions(): array
{
return [
Expand Down
26 changes: 26 additions & 0 deletions src/Component/Tests/Dummy/AttributeFooGrid.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<?php

/*
* This file is part of the Sylius package.
*
* (c) Sylius Sp. z o.o.
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace Sylius\Component\Grid\Tests\Dummy;

use Sylius\Bundle\GridBundle\Builder\GridBuilderInterface;
use Sylius\Bundle\GridBundle\Grid\AbstractGrid;
use Sylius\Component\Grid\Metadata\AsGrid;

#[AsGrid(name: 'app_foo_with_attribute', resourceClass: Foo::class)]
final class AttributeFooGrid extends AbstractGrid
{
public function buildGrid(GridBuilderInterface $gridBuilder): void
{
}
}

0 comments on commit 4ad598f

Please sign in to comment.