Created
August 23, 2010 11:50
-
-
Save ornicar/545320 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* The problem | |
* ----------- | |
* People start to build Symfony2 Bundles which need a database. | |
* Instead of having ORM-only Bundles and ODM-only Bundles, | |
* people try to make Bundles more generic, for obvious reasons. | |
* | |
* A proposition | |
* ---------- | |
* Here is a proposition of a minimalist interface that | |
* EntityManager and DocumentManager could implement. | |
* It could make Bundle developers life easier. | |
* This is just a draft designed to create a discussion. | |
* All these methods already exist in ORM and ODM. | |
* I'm not sure if they make sense with CouchDB. | |
* Thoughts? | |
*/ | |
interface ObjectManagerInterface | |
{ | |
/** | |
* Tells the ObjectManager to make an instance managed and persistent. | |
*/ | |
public function persist($object); | |
/** | |
* Removes a document instance. | |
*/ | |
public function remove($object); | |
/** | |
* Refreshes the persistent state of an object from the database, | |
* overriding any local changes that have not yet been persisted. | |
*/ | |
public function refresh($object); | |
/** | |
* Detaches a document from the DocumentManager, causing a managed object to | |
* become detached. Unflushed changes made to the object if any | |
* (including removal of the document), will not be synchronized to the database. | |
* Objects which previously referenced the detached object will continue to | |
* reference it. | |
*/ | |
public function detach($document); | |
/** | |
* Flushes all changes to objects that have been queued up to now to the database. | |
* This effectively synchronizes the in-memory state of managed objects with the | |
* database. | |
*/ | |
public function flush(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Yeah we reproduced on ForumBundle the strategy I tried for DoctrineUserBundle. It looks usable, but will only work with Doctrine. And I assume entity and document mappers share methods like "persist" and "flush".