Skip to content

Commit

Permalink
update doc with php const in yaml
Browse files Browse the repository at this point in the history
  • Loading branch information
vasilvestre committed Oct 22, 2024
1 parent 215bc11 commit 12a8575
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
4 changes: 2 additions & 2 deletions docs/custom_filter.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use Sylius\Bundle\GridBundle\Doctrine\DataSourceInterface;
use Sylius\Component\Grid\Filtering\FilterInterface;
use Sylius\Component\Grid\Metadata\AsFilter;

#[AsFilter(type: 'suppliers_statistics', formType: SuppliersStatisticsFilterType::class)]
#[AsFilter(formType: SuppliersStatisticsFilterType::class)]
class SuppliersStatisticsFilter implements FilterInterface
{
public function apply(DataSourceInterface $dataSource, $name, $data, array $options = []): void
Expand Down Expand Up @@ -108,7 +108,7 @@ sylius_grid:
resource: app.tournament
filters:
stats:
type: suppliers_statistics
type: !php/const App\Grid\Filter\SuppliersStatisticsFilter::class
form_options:
range: [0, 100]
templates:
Expand Down
1 change: 1 addition & 0 deletions src/Bundle/DependencyInjection/SyliusGridExtension.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
use Symfony\Component\Config\FileLocator;
use Symfony\Component\DependencyInjection\ChildDefinition;
use Symfony\Component\DependencyInjection\ContainerBuilder;
use Symfony\Component\DependencyInjection\Exception\LogicException;
use Symfony\Component\DependencyInjection\Extension\Extension;
use Symfony\Component\DependencyInjection\Loader\XmlFileLoader;

Expand Down
6 changes: 5 additions & 1 deletion src/Component/Metadata/AsFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,9 +16,13 @@
#[\Attribute(\Attribute::TARGET_CLASS)]
final class AsFilter
{
/**
* @param string $formType The form type class name
* @param string|null $type The filter type (defaults to FQCN of the class)
*/
public function __construct(
public string $formType,
public ?string $type = null,
public ?string $formType = null,
) {
}
}

0 comments on commit 12a8575

Please sign in to comment.