gregosphatos/doctrine-filters-bundle

Some nice doctrine filters

Installs: 3 504

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 0

Open Issues: 0

Type:symfony-bundle

1.0.2 2015-08-28 18:44 UTC

This package is not auto-updated.

Last update: 2024-04-27 15:47:48 UTC


README

Build Status Latest Stable Version Total Downloads Latest Unstable Version License

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.

Composer documentation

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.