@@ -185,21 +185,19 @@ When working with multiple entity managers to update your schema:
185185 If you *do * omit the entity manager's name when asking for it,
186186the default entity manager (i.e. ``default ``) is returned::
187187
188- use Doctrine\ORM\EntityManagerInterface;
189- use Doctrine\Common\Persistence\ManagerRegistry;
188+ // ...
190189
191190 class UserController extends Controller
192191 {
193- public function indexAction(EntityManagerInterface $em, ManagerRegistry $doctrine )
192+ public function indexAction()
194193 {
195- // All 4 return the "default" entity manager
196- // $em from the EntityManagerInterface
197- $em = $doctrine->getManager();
198- $em = $doctrine->getManager('default');
194+ // All 3 return the "default" entity manager
195+ $em = $this->getDoctrine()->getManager();
196+ $em = $this->getDoctrine()->getManager('default');
199197 $em = $this->get('doctrine.orm.default_entity_manager');
200198
201199 // Both of these return the "customer" entity manager
202- $customerEm = $doctrine ->getManager('customer');
200+ $customerEm = $this->getDoctrine() ->getManager('customer');
203201 $customerEm = $this->get('doctrine.orm.customer_entity_manager');
204202 }
205203 }
@@ -210,26 +208,29 @@ entity manager to persist and fetch its entities.
210208
211209The same applies to repository calls::
212210
213- use Doctrine\Common\Persistence\ManagerRegistry;
214211 use AcmeStoreBundle\Entity\Customer;
215212 use AcmeStoreBundle\Entity\Product;
213+ // ...
216214
217215 class UserController extends Controller
218216 {
219- public function indexAction(ManagerRegistry $doctrine )
217+ public function indexAction()
220218 {
221219 // Retrieves a repository managed by the "default" em
222- $products = $doctrine->getRepository(Product::class)
220+ $products = $this->getDoctrine()
221+ ->getRepository(Product::class)
223222 ->findAll()
224223 ;
225224
226225 // Explicit way to deal with the "default" em
227- $products = $doctrine->getRepository(Product::class, 'default')
226+ $products = $this->getDoctrine()
227+ ->getRepository(Product::class, 'default')
228228 ->findAll()
229229 ;
230230
231231 // Retrieves a repository managed by the "customer" em
232- $customers = $doctrine->getRepository(Customer::class, 'customer')
232+ $customers = $this->getDoctrine()
233+ ->getRepository(Customer::class, 'customer')
233234 ->findAll()
234235 ;
235236 }
0 commit comments