Skip to content

Commit 8b54ed7

Browse files
committed
Document repository calls with multiple em
1 parent ad790f2 commit 8b54ed7

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed

cookbook/doctrine/multiple_entity_managers.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,3 +69,26 @@ the default entity manager (i.e. ``default``) is returned::
6969
You can now use Doctrine just as you did before - using the ``default`` entity
7070
manager to persist and fetch entities that it manages and the ``customer``
7171
entity manager to persist and fetch its entities.
72+
73+
The same applies to repository call::
74+
75+
class UserController extends Controller
76+
{
77+
public function indexAction()
78+
{
79+
// Retrieves a repository managed by the "default" em
80+
$products = $this->get('doctrine')
81+
->getRepository('AcmeStoreBundle:Product')
82+
->findAll();
83+
84+
// Explicit way to deal with the "default" em
85+
$products = $this->get('doctrine')
86+
->getRepository('AcmeStoreBundle:Product', 'default')
87+
->findAll();
88+
89+
// Retrieves a repository managed by the "customer" em
90+
$customers = $this->get('doctrine')
91+
->getRepository('AcmeCustomerBundle:Customer', 'customer')
92+
->findAll();
93+
}
94+
}

0 commit comments

Comments
 (0)