Implementation of Repository pattern for Doctrine ORM
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.
- 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');
...