-1

How do I use QueryBuilder in a service container?

For exemple :

services:
my.service:
    class: My\MyBundle\UserAdmin
    arguments: [ ~, My\MyBundle\Entity\User,~ ]

How can i access QueryBuilder for select only the Users loggeds (this is just a exemple) ? It is possible ?

PululuK
  • 113
  • 1
  • 6

1 Answers1

-3

Injet doctrine entity manager to the service definition :

 arguments: ["@doctrine.orm.entity_manager"]

In the constructor of the service :

public function __constructor(EntityManager $entityManager)
    {
        $this->em = $entityManager;
    }
Ohda
  • 20
  • 1