mirror of
https://github.com/doctrine/orm.git
synced 2026-03-23 22:42:18 +01:00
[PR #959] [CLOSED] Implemented an ObjectPersisterInterface for entity/object storage #8963
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/doctrine/orm/pull/959
Author: @linaori
Created: 2/21/2014
Status: ❌ Closed
Base:
master← Head:master📝 Commits (1)
c09bcb8Implemented an ObjectPersisterInterface for entity/object storage📊 Changes
2 files changed (+20 additions, -1 deletions)
View changed files
📝
lib/Doctrine/ORM/EntityManager.php(+1 -1)➕
lib/Doctrine/ORM/ObjectPersisterInterface.php(+19 -0)📄 Description
Moved to: https://github.com/doctrine/common/pull/317
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 anEntityManagerInterfaceto provide persist/flush. We don't want the entireEntityManagerInterfacecapabilities just to store an object.Using the
ObjectPersisterInterfacewe can "hide" theEntityManagerInterfaceand only let the code know we have the persist and flush methods available. By default this is implemented on theEntityManager, but is also possible to be mocked or replaced by a custom implementation (rotating entity managers?).Example
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.