Skip to content

Add possibility to enable filters #750

Open
@darckking

Description

@darckking

Currently the Doctrine filters can be added to EntityManager's Configuration object by providing them in configuration array as:

'filters' => [
    'filter-name' => 'FilterClass'
]

However, they're disabled by default and need to be explicitly enabled by calling $entityManager->getFilters()->enable('filter-name')
Usually, I'd put filters initialization in Module, that implements BootstrapListenerInterface, inside the onBootstrap() function but if application uses laminas-cli this function won't be called as laminas-cli doesn't lift the whole app.

In ideal scenario filters should be configured and enabled in one place and it should work for both web and cli. Just like it works in
Doctrine Bundle for Symfony.

filters:
    filter-name:
        class: FilterClass
        enabled: true

I looked in EntityManager internals and the $filterCollection property is initialized only on the first call of getFilters(), hence filters can be enabled only after EntityManager was instantiated.

So what's the opinion about it, should it be in scope of DoctrineORMModule to enable filters like Doctrine Bundle for Symfony does or it's up to users to enable them ?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions