Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor handling of BSON filters #1986

Open
alcaeus opened this issue Mar 29, 2019 · 0 comments
Open

Refactor handling of BSON filters #1986

alcaeus opened this issue Mar 29, 2019 · 0 comments

Comments

@alcaeus
Copy link
Member

alcaeus commented Mar 29, 2019

Feature Request

Q A
New Feature yes
RFC yes
BC Break not yet

Summary

The Configuration::addFilter method currently only allows adding a filter by specifying its name, class and optional parameters. When needed, those filters are instantiated by the FilterCollection according to the configuration. There are several issues with this approach:

  • The base class for filters specifies a final constructor that takes a DocumentManager instance. This makes it impossible to create more complex filters that might rely on other objects to do their work
  • Due to FilterCollection instantiating the filters itself, they cannot be configured as services in the Symfony Bundle (see Dependency Injection and ODM Filter DoctrineMongoDBBundle#547). Similar to that, using dependency injection to inject other services is impossible due to the constructor as mentioned above.

To alleviate these pains, the filter handling should be changed completely to allow more flexibility:

  • Instead of providing an abstract class with a final constructor, we should provide an interface that must be implemented by each filter
  • The addFilterCriteria should not only receive a ClassMetadata instance but also the document manager in use. This allows reusing a filter instance for multiple document managers
  • The addFilter method in Configuration needs to be extended to allow adding a filter instance to the configuration instead of just its class name. FilterCollection must be added accordingly.

The old way of adding filters should be deprecated and dropped in 3.0. Until then, both ways of adding filters will be supported.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant