DDC-2994: [GH-959] Implemented an ObjectPersisterInterface for entity/object storage #3719

Closed
opened 2026-01-22 14:26:12 +01:00 by admin · 3 comments
Owner

Originally created by @doctrinebot on GitHub (Feb 21, 2014).

Originally assigned to: @Ocramius on GitHub.

Jira issue originally created by user @doctrinebot:

This issue is created automatically through a Github pull request on behalf of iltar:

Url: https://github.com/doctrine/doctrine2/pull/959

Message:

Why is this useful?

Instead of using the repositoryClass, we use 'Repository as a Service'. This means that we inject our repository service instead of doing $em->getRepository('MyEntity'), this provides typehinting and autocomplete in IDEs. This introduces a minor inconvenience, we need to inject an EntityManagerInterface to provide persist/flush. We don't want the entire EntityManagerInterface capabilities just to store an object.

Using the ObjectPersisterInterface we can "hide" the EntityManagerInterface and only let the code know we have the persist and flush methods available. By default this is implemented on the EntityManager, but is also possible to be mocked or replaced by a custom implementation (rotating entity managers?).

Originally created by @doctrinebot on GitHub (Feb 21, 2014). Originally assigned to: @Ocramius on GitHub. Jira issue originally created by user @doctrinebot: This issue is created automatically through a Github pull request on behalf of iltar: Url: https://github.com/doctrine/doctrine2/pull/959 Message: ### Why is this useful? Instead of using the `repositoryClass`, we use 'Repository as a Service'. This means that we inject our repository service instead of doing `$em->getRepository('MyEntity')`, this provides typehinting and autocomplete in IDEs. This introduces a minor inconvenience, we need to inject an `EntityManagerInterface` to provide persist/flush. We don't want the entire `EntityManagerInterface` capabilities just to store an object. Using the `ObjectPersisterInterface` we can "hide" the `EntityManagerInterface` and only let the code know we have the persist and flush methods available. By default this is implemented on the `EntityManager`, but is also possible to be mocked or replaced by a custom implementation (rotating entity managers?).
admin added the Improvement label 2026-01-22 14:26:12 +01:00
admin closed this issue 2026-01-22 14:26:13 +01:00
Author
Owner

@doctrinebot commented on GitHub (Feb 21, 2014):

@doctrinebot commented on GitHub (Feb 21, 2014): - duplicates [DCOM-235: [GH-317] Implemented an ObjectPersisterInterface for entity/object storage](http://www.doctrine-project.org/jira/browse/DCOM-235)
Author
Owner

@doctrinebot commented on GitHub (Feb 21, 2014):

Comment created by @doctrinebot:

A related Github Pull-Request [GH-959] was closed:
https://github.com/doctrine/doctrine2/pull/959

@doctrinebot commented on GitHub (Feb 21, 2014): Comment created by @doctrinebot: A related Github Pull-Request [GH-959] was closed: https://github.com/doctrine/doctrine2/pull/959
Author
Owner

@doctrinebot commented on GitHub (Feb 21, 2014):

Issue was closed with resolution "Duplicate"

@doctrinebot commented on GitHub (Feb 21, 2014): Issue was closed with resolution "Duplicate"
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#3719