lag/doctrine-repository

Generic admin bundle for Symfony2 from L'Arrière Guichet

dev-master 2016-04-11 22:18 UTC

This package is auto-updated.

Last update: 2024-10-21 19:46:48 UTC


README

Build Status

DoctrineRepositoryBundle

Implementation of Repository pattern for Doctrine ORM

Introduction

This bundle allows developpers to retrieve a Doctrine repository without passing by the EntityManager. Thoses repositories are exposed as service and constructed without using the Doctrine repository factory.

Example

  • Define your repository class in your Doctrine entity as usual
/**
 * Article
 *
 * @ORM\Table(name="article")
 * @ORM\Entity(repositoryClass="MyVendor\MyBundle\Repository\ArticleRepository")
 * @ORM\HasLifecycleCallbacks()
 */
class Article {
...
  • Define the service with the tag "doctrine_repository"
    my_repository:
        class: MyVendor\MyBundle\Repository\ArticleRepository
        tags:
            - {name: doctrine.repository}
  • Retrieve your repository from service container :
...
$this->get('my_repository');
...