I am currently implementing Doctrine filters in my Symfony2.1 project with the following setting:
<?php namespace Acme\Bundle\Entity; class Article { /** * @ORM\Column(type="string") */ private $status; ... } //app/config/config.yml doctrine: orm: filters: status: class: Acme\Bundle\Filter\StatusFilter enabled: false .... //src/Acme/Bundle/Filter/StatusFilter.php namespace Acme\Bundle\Filter; use Acme\Bundle\Entity\Status; class StatusFilter extends SQLFilter { public function addFilterConstraint(ClassMetadata $target, $alias) { $filter = $target->reflClass->implementsInterface('Acme\Bundle\Entity\Status')? $alias . '.status = ' . Status::PUBLISHED : ''; return $filter; } }
Where Acme \ Bundle \ Entity \ Status is just an interface.
The code works as expected when the filter is enabled in config.yml .
The problem is that I cannot get all the articles for administration!
Is there a way to enable this filter for a specific package?
postscript I know how to enable and disable the filter with EntityManager,
I just can't find a suitable place to do this for the front-end package.
My admin section is accessible via myadmin route prefix myadmin
www.example.com/myadmin/-> admin section = disable the filter (disabled by default) www.example.com / ... → anything else = enable the filter.
source share