Skip to content

larriereguichet/DoctrineRepositoryBundle

Repository files navigation

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');
...

About

Implementation of Repository pattern for Doctrine ORM

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages