@@ -115,15 +115,41 @@ fos_elastica:
115115
116116An example for using a repository :
117117
118+ ` ` ` yaml
119+ # config/services.yaml
120+ services:
121+ # ...
122+
123+ App\C ontroller\UserContr oller:
124+ tags: ['controller.service_arguments']
125+ public: true
126+ arguments:
127+ - '@fos_elastica.manager'
128+ ` ` `
129+
118130` ` ` php
119- /** var FOS\E lasticaBundle\M anager\R epositoryManager */
120- $repositoryManager = $this->container->get('fos_elastica.manager');
131+ namespace App\C ontroller;
132+
133+ use FOS\E lasticaBundle\M anager\R epositoryManagerInterface;
134+
135+ class UserController extends Controller
136+ {
137+ /** @var RepositoryManagerInterface */
138+ private $repositoryManager;
139+
140+ public function __construct(RepositoryManagerInterface $repositoryManager)
141+ {
142+ $this->repositoryManager = $repositoryManager;
143+ }
121144
122- /** var FOS\E lasticaBundle\R epository */
123- $repository = $repositoryManager->getRepository('UserBundle:User');
145+ public function userAction()
146+ {
147+ $repository = $this->repositoryManager->getRepository('UserBundle:User');
124148
125- /** var array of Acme\UserBundl e\E ntity\U ser */
126- $users = $repository->find('bob');
149+ /** var array of App\UserBundl e\E ntity\U ser */
150+ $users = $repository->find('bob');
151+ }
152+ }
127153` ` `
128154
129155For more information about customising repositories, see the cookbook entry
@@ -160,10 +186,10 @@ class UserRepository extends EntityRepository
160186 public function createSearchQueryBuilder($entityAlias)
161187 {
162188 $qb = $this->createQueryBuilder($entityAlias);
163-
189+
164190 $qb->select($entityAlias, 'g')
165191 ->innerJoin($entityAlias.'.groups', 'g');
166-
192+
167193 return $qb;
168194 }
169195}
0 commit comments