Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 8b54ed7

Browse filesBrowse files
committed
Document repository calls with multiple em
1 parent ad790f2 commit 8b54ed7
Copy full SHA for 8b54ed7

File tree

Expand file treeCollapse file tree

1 file changed

+23
-0
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+23
-0
lines changed

‎cookbook/doctrine/multiple_entity_managers.rst

Copy file name to clipboardExpand all lines: cookbook/doctrine/multiple_entity_managers.rst
+23Lines 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 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.