3 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
4 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
5 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
6 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
7 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
8 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
9 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
10 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
11 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
12 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
13 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
15 * This software consists of voluntary contributions made by many individuals
16 * and is licensed under the MIT license. For more information, see
17 * <http://www.doctrine-project.org>.
20 namespace Doctrine\Common\Persistence;
23 * Contract for a Doctrine persistence layer ObjectManager class to implement.
25 * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
26 * @link www.doctrine-project.org
28 * @author Benjamin Eberlei <kontakt@beberlei.de>
29 * @author Jonathan Wage <jonwage@gmail.com>
31 interface ObjectManager
34 * Finds a object by its identifier.
36 * This is just a convenient shortcut for getRepository($className)->find($id).
42 function find($className, $id);
45 * Tells the ObjectManager to make an instance managed and persistent.
47 * The object will be entered into the database as a result of the flush operation.
49 * NOTE: The persist operation always considers objects that are not yet known to
50 * this ObjectManager as NEW. Do not pass detached objects to the persist operation.
52 * @param object $object The instance to make managed and persistent.
54 function persist($object);
57 * Removes an object instance.
59 * A removed object will be removed from the database as a result of the flush operation.
61 * @param object $object The object instance to remove.
63 function remove($object);
66 * Merges the state of a detached object into the persistence context
67 * of this ObjectManager and returns the managed copy of the object.
68 * The object passed to merge will not become associated/managed with this ObjectManager.
70 * @param object $object
73 function merge($object);
76 * Clears the ObjectManager. All objects that are currently managed
77 * by this ObjectManager become detached.
79 * @param string $objectName if given, only objects of this type will get detached
81 function clear($objectName = null);
84 * Detaches an object from the ObjectManager, causing a managed object to
85 * become detached. Unflushed changes made to the object if any
86 * (including removal of the object), will not be synchronized to the database.
87 * Objects which previously referenced the detached object will continue to
90 * @param object $object The object to detach.
92 function detach($object);
95 * Refreshes the persistent state of an object from the database,
96 * overriding any local changes that have not yet been persisted.
98 * @param object $object The object to refresh.
100 function refresh($object);
103 * Flushes all changes to objects that have been queued up to now to the database.
104 * This effectively synchronizes the in-memory state of managed objects with the
110 * Gets the repository for a class.
112 * @param string $className
113 * @return \Doctrine\Common\Persistence\ObjectRepository
115 function getRepository($className);
118 * Returns the ClassMetadata descriptor for a class.
120 * The class name must be the fully-qualified class name without a leading backslash
121 * (as it is returned by get_class($obj)).
123 * @param string $className
124 * @return \Doctrine\Common\Persistence\Mapping\ClassMetadata
126 function getClassMetadata($className);
129 * Gets the metadata factory used to gather the metadata of classes.
131 * @return \Doctrine\Common\Persistence\Mapping\ClassMetadataFactory
133 function getMetadataFactory();
136 * Helper method to initialize a lazy loading proxy or persistent collection.
138 * This method is a no-op for other objects.
142 function initializeObject($obj);
145 * Check if the object is part of the current UnitOfWork and therefore
148 * @param object $object
151 function contains($object);