gregosphatos / doctrine-filters-bundle
Some nice doctrine filters
Installs: 3 506
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 0
Open Issues: 0
Type:symfony-bundle
Requires
- php: >=5.3.0
- doctrine/common: ~2.4
- doctrine/mongodb-odm: ~1.0.0
- doctrine/orm: ~2.2,>=2.2.3
Requires (Dev)
- fabpot/php-cs-fixer: ^1.10
- phpmd/phpmd: @stable
- phpunit/phpunit: 4.1.*
- squizlabs/php_codesniffer: 2.*
This package is not auto-updated.
Last update: 2025-03-01 19:58:10 UTC
README
DoctrineFiltersBundle provides integration for DoctrineFilters for your Symfony2 Project.
Installation
With composer :
Install composer on Linux / Mac OS
curl -sS https://getcomposer.org/installer | php
sudo mv composer.phar /usr/local/bin/composer
To install composer on Windows download the installer from getcomposer.org/download, execute it and follow the instructions.
Add this on your composer.json
"require": { "gregosphatos/doctrine-filters-bundle": "~1.0" }
Documentation
Record state filter
This filter is really usefull for all db recordset that need to be statued (active, inactive). Available for Doctrine ORM and Doctrine mongo ODM :
in your config.yml :
orm: entity_managers: # Your own entity manager collection some_em: filters: state_filter: class: GreGosPhaTos\DoctrineFiltersBundle\Doctrine\Filter\ORM\RecordStateFilter enabled: true
or
doctrine_mongodb: document_managers: # Your own document manager collection some_dm: filters: state_filter: class: GreGosPhaTos\DoctrineFiltersBundle\Doctrine\Filter\ODM\RecordStateFilter enabled: true
Manually add the configurator in your service.yml :
services: # ORM acme.doctrine.orm.filter.configurator: class: GreGosPhaTos\DoctrineFiltersBundle\Doctrine\Filter\ORM\Configurator arguments: - "@doctrine.orm.entity_manager" - "@annotation_reader" tags: - { name: kernel.event_listener, event: kernel.request } # ODM acme.doctrine.odm.filter.configurator: class: GreGosPhaTos\DoctrineFiltersBundle\Doctrine\Filter\ODM\Configurator arguments: - "@doctrine_mongodb.odm.document_manager" - "@annotation_reader" tags: - { name: kernel.event_listener, event: kernel.request }
Change your entities or documents :
use GreGosPhaTos\DoctrineFiltersBundle\Doctrine\Annotation\RecordState; /** * Entity. * * @RecordState(stateFieldName="state", activeValue="active") */ class MyEntity { /** * Record state * possible values : active, inactive */ private $state; }
Then all the queries will be filter to get only the active records.