Skip to content

Warn use if filter method is called without saveFilter #26

@garak

Description

@garak

If you forget calling saveFilter and call filter directly, the $forms property in the service is empty, causing a notice in the filter method and making it not work.
We should add a check and raise an exception to ease debugging.

Good example:

<?php
public function action(Filter $filter): Response
{
   $filter->saveFilter(MyFilterType::class, 'my_name');
   $filters = $filter->filter('my_name');
   // etc...   
}

Bad example:

<?php
public function action(Filter $filter): Response
{
   $filters = $filter->filter('my_name'); // <-- forgot saving the filter, not working!
   // etc...   
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions