Skip to content

Commit 203f440

Browse files
committed
minor #14643 Update multiple_entity_managers.rst (noniagriconomie)
This PR was squashed before being merged into the 4.4 branch. Discussion ---------- Update multiple_entity_managers.rst Document the way to bind this second entity manager so that it is injectable via typehint binding Commits ------- 9a80b1b Update multiple_entity_managers.rst
2 parents ac90ac8 + 9a80b1b commit 203f440

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

doctrine/multiple_entity_managers.rst

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,17 @@ the default entity manager (i.e. ``default``) is returned::
254254
}
255255
}
256256

257+
You can leverage the service binding feature to reference the ``customer``
258+
entity manager so that you can inject it directly::
259+
260+
services:
261+
_defaults:
262+
bind:
263+
$customerEntityManager: '@doctrine.orm.customer_entity_manager'
264+
265+
Now type-hint your method with ``EntityManagerInterface $customerEntityManager``
266+
to inject this second entity manager as dependency.
267+
257268
You can now use Doctrine like you did before - using the ``default`` entity
258269
manager to persist and fetch entities that it manages and the ``customer``
259270
entity manager to persist and fetch its entities.

0 commit comments

Comments
 (0)