sonata-project / SonataAdminBundle

The missing Symfony Admin Generator
https://docs.sonata-project.org/projects/SonataAdminBundle
MIT License
2.11k stars 1.26k forks source link

Remove alias parameter from FilterInterface::filter #6269

Closed franmomu closed 3 years ago

franmomu commented 4 years ago

Feature Request

Right now Sonata\AdminBundle\Filter\FilterInterface::filter() is declared like:

public function filter(ProxyQueryInterface $queryBuilder, $alias, $field, $value);

The $alias parameter is specific to the ORM implementation, we should removed it to make it agnostic from the persistence layer.

To solve this in SonataDoctrineORMAdminBundle, we can probably use QueryBuilder::getRootAlias() method.

Also remove from ModelManagerInterface::createQuery($class, $alias = 'o')

VincentLanglet commented 3 years ago

@franmomu I think the filter method should be removed from the interface.

The filter method is used by the apply one https://github.com/sonata-project/SonataDoctrineMongoDBAdminBundle/blob/3.x/src/Filter/Filter.php#L22 https://github.com/sonata-project/SonataDoctrineORMAdminBundle/blob/3.x/src/Filter/Filter.php#L27

The abstract class Filter of the persistence bundle should just have an abstract protected filter() method instead.

franmomu commented 3 years ago

@franmomu I think the filter method should be removed from the interface.

The filter method is used by the apply one https://github.com/sonata-project/SonataDoctrineMongoDBAdminBundle/blob/3.x/src/Filter/Filter.php#L22 https://github.com/sonata-project/SonataDoctrineORMAdminBundle/blob/3.x/src/Filter/Filter.php#L27

The abstract class Filter of the persistence bundle should just have an abstract protected filter() method instead.

Interesting, that would be easier than deprecate the second argument which I had no idea how to do it.