Skip to content

Example of getting entity managers directly from the container #3545

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 16, 2014
Merged

Example of getting entity managers directly from the container #3545

merged 1 commit into from
Feb 16, 2014

Conversation

colinodell
Copy link
Contributor

The documentation didn't provide examples of how to obtain the entity managers directly from the DI container. This is useful when needing to inject the em into other services.

The ems are added to the container using the service id doctrine.orm.%s_entity_manager, where %s is the em's name. This is done by \Doctrine\Bundle\DoctrineBundle\DependencyInjection\DoctrineExtension::loadOrmEntityManager()

Q A
Doc fix? no
New docs? yes? (added example of existing feature)
Applies to all (doctrine/doctrine-bundle v1.0.0+)
Fixed tickets n/a

The documentation didn't provide examples of how to obtain the entity managers directly from the DI container.  This is useful when needing to inject the em into other services.

The ems are added to the container using the service id `doctrine.orm.%s_entity_manager`, where `%s` is the em's name.  This is done by `\Doctrine\Bundle\DoctrineBundle\DependencyInjection\DoctrineExtension::loadOrmEntityManager()` (see: https://github.com/doctrine/DoctrineBundle/blob/v1.2.0/DependencyInjection/DoctrineExtension.php#L347)
@colinodell
Copy link
Contributor Author

The functionality has been part of doctrine/doctrine-bundle since 1.0.0 (source), but wasn't mentioned in a relevant area of the documentation.

@weaverryan
Copy link
Member

Hey Colin! Brilliant explanation! I really like this change :). Thanks!

weaverryan added a commit that referenced this pull request Feb 16, 2014
…ainer (colinodell)

This PR was merged into the 2.3 branch.

Discussion
----------

Example of getting entity managers directly from the container

The documentation didn't provide examples of how to obtain the entity managers directly from the DI container.  This is useful when needing to inject the em into other services.

The ems are added to the container using the service id `doctrine.orm.%s_entity_manager`, where `%s` is the em's name.  This is done by [`\Doctrine\Bundle\DoctrineBundle\DependencyInjection\DoctrineExtension::loadOrmEntityManager()`](https://github.com/doctrine/DoctrineBundle/blob/v1.0.0/DependencyInjection/DoctrineExtension.php#L342)

| Q             | A
| ------------- | ---
| Doc fix?      | no
| New docs?     | yes? (added example of existing feature)
| Applies to    | all (doctrine/doctrine-bundle v1.0.0+)
| Fixed tickets | n/a

Commits
-------

eb7594c Example of getting entity managers directly from the container
@weaverryan weaverryan merged commit eb7594c into symfony:2.3 Feb 16, 2014
@colinodell colinodell deleted the patch-1 branch February 16, 2014 20:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants