Chris@0: . Chris@0: */ Chris@0: Chris@0: namespace Doctrine\Common\Persistence; Chris@0: Chris@0: /** Chris@0: * Contract for a Doctrine persistence layer ObjectManager class to implement. Chris@0: * Chris@0: * @link www.doctrine-project.org Chris@0: * @since 2.1 Chris@0: * @author Benjamin Eberlei Chris@0: * @author Jonathan Wage Chris@0: */ Chris@0: interface ObjectManager Chris@0: { Chris@0: /** Chris@0: * Finds an object by its identifier. Chris@0: * Chris@0: * This is just a convenient shortcut for getRepository($className)->find($id). Chris@0: * Chris@0: * @param string $className The class name of the object to find. Chris@0: * @param mixed $id The identity of the object to find. Chris@0: * Chris@0: * @return object The found object. Chris@0: */ Chris@0: public function find($className, $id); Chris@0: Chris@0: /** Chris@0: * Tells the ObjectManager to make an instance managed and persistent. Chris@0: * Chris@0: * The object will be entered into the database as a result of the flush operation. Chris@0: * Chris@0: * NOTE: The persist operation always considers objects that are not yet known to Chris@0: * this ObjectManager as NEW. Do not pass detached objects to the persist operation. Chris@0: * Chris@0: * @param object $object The instance to make managed and persistent. Chris@0: * Chris@0: * @return void Chris@0: */ Chris@0: public function persist($object); Chris@0: Chris@0: /** Chris@0: * Removes an object instance. Chris@0: * Chris@0: * A removed object will be removed from the database as a result of the flush operation. Chris@0: * Chris@0: * @param object $object The object instance to remove. Chris@0: * Chris@0: * @return void Chris@0: */ Chris@0: public function remove($object); Chris@0: Chris@0: /** Chris@0: * Merges the state of a detached object into the persistence context Chris@0: * of this ObjectManager and returns the managed copy of the object. Chris@0: * The object passed to merge will not become associated/managed with this ObjectManager. Chris@0: * Chris@0: * @param object $object Chris@0: * Chris@0: * @return object Chris@0: */ Chris@0: public function merge($object); Chris@0: Chris@0: /** Chris@0: * Clears the ObjectManager. All objects that are currently managed Chris@0: * by this ObjectManager become detached. Chris@0: * Chris@0: * @param string|null $objectName if given, only objects of this type will get detached. Chris@0: * Chris@0: * @return void Chris@0: */ Chris@0: public function clear($objectName = null); Chris@0: Chris@0: /** Chris@0: * Detaches an object from the ObjectManager, causing a managed object to Chris@0: * become detached. Unflushed changes made to the object if any Chris@0: * (including removal of the object), will not be synchronized to the database. Chris@0: * Objects which previously referenced the detached object will continue to Chris@0: * reference it. Chris@0: * Chris@0: * @param object $object The object to detach. Chris@0: * Chris@0: * @return void Chris@0: */ Chris@0: public function detach($object); Chris@0: Chris@0: /** Chris@0: * Refreshes the persistent state of an object from the database, Chris@0: * overriding any local changes that have not yet been persisted. Chris@0: * Chris@0: * @param object $object The object to refresh. Chris@0: * Chris@0: * @return void Chris@0: */ Chris@0: public function refresh($object); Chris@0: Chris@0: /** Chris@0: * Flushes all changes to objects that have been queued up to now to the database. Chris@0: * This effectively synchronizes the in-memory state of managed objects with the Chris@0: * database. Chris@0: * Chris@0: * @return void Chris@0: */ Chris@0: public function flush(); Chris@0: Chris@0: /** Chris@0: * Gets the repository for a class. Chris@0: * Chris@0: * @param string $className Chris@0: * Chris@0: * @return \Doctrine\Common\Persistence\ObjectRepository Chris@0: */ Chris@0: public function getRepository($className); Chris@0: Chris@0: /** Chris@0: * Returns the ClassMetadata descriptor for a class. Chris@0: * Chris@0: * The class name must be the fully-qualified class name without a leading backslash Chris@0: * (as it is returned by get_class($obj)). Chris@0: * Chris@0: * @param string $className Chris@0: * Chris@0: * @return \Doctrine\Common\Persistence\Mapping\ClassMetadata Chris@0: */ Chris@0: public function getClassMetadata($className); Chris@0: Chris@0: /** Chris@0: * Gets the metadata factory used to gather the metadata of classes. Chris@0: * Chris@0: * @return \Doctrine\Common\Persistence\Mapping\ClassMetadataFactory Chris@0: */ Chris@0: public function getMetadataFactory(); Chris@0: Chris@0: /** Chris@0: * Helper method to initialize a lazy loading proxy or persistent collection. Chris@0: * Chris@0: * This method is a no-op for other objects. Chris@0: * Chris@0: * @param object $obj Chris@0: * Chris@0: * @return void Chris@0: */ Chris@0: public function initializeObject($obj); Chris@0: Chris@0: /** Chris@0: * Checks if the object is part of the current UnitOfWork and therefore managed. Chris@0: * Chris@0: * @param object $object Chris@0: * Chris@0: * @return bool Chris@0: */ Chris@0: public function contains($object); Chris@0: }