Rajout de doctrine/orm
[zf2.biz/galerie.git] / vendor / doctrine / common / lib / Doctrine / Common / Persistence / ObjectManager.php
1 <?php
2 /*
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.
14  *
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>.
18  */
19
20 namespace Doctrine\Common\Persistence;
21
22 /**
23  * Contract for a Doctrine persistence layer ObjectManager class to implement.
24  *
25  * @license http://www.opensource.org/licenses/lgpl-license.php LGPL
26  * @link    www.doctrine-project.org
27  * @since   2.1
28  * @author  Benjamin Eberlei <kontakt@beberlei.de>
29  * @author  Jonathan Wage <jonwage@gmail.com>
30  */
31 interface ObjectManager
32 {
33     /**
34      * Finds a object by its identifier.
35      *
36      * This is just a convenient shortcut for getRepository($className)->find($id).
37      *
38      * @param string
39      * @param mixed
40      * @return object
41      */
42     function find($className, $id);
43
44     /**
45      * Tells the ObjectManager to make an instance managed and persistent.
46      *
47      * The object will be entered into the database as a result of the flush operation.
48      *
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.
51      *
52      * @param object $object The instance to make managed and persistent.
53      */
54     function persist($object);
55
56     /**
57      * Removes an object instance.
58      *
59      * A removed object will be removed from the database as a result of the flush operation.
60      *
61      * @param object $object The object instance to remove.
62      */
63     function remove($object);
64
65     /**
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.
69      *
70      * @param object $object
71      * @return object
72      */
73     function merge($object);
74
75     /**
76      * Clears the ObjectManager. All objects that are currently managed
77      * by this ObjectManager become detached.
78      *
79      * @param string $objectName if given, only objects of this type will get detached
80      */
81     function clear($objectName = null);
82
83     /**
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
88      * reference it.
89      *
90      * @param object $object The object to detach.
91      */
92     function detach($object);
93
94     /**
95      * Refreshes the persistent state of an object from the database,
96      * overriding any local changes that have not yet been persisted.
97      *
98      * @param object $object The object to refresh.
99      */
100     function refresh($object);
101
102     /**
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
105      * database.
106      */
107     function flush();
108
109     /**
110      * Gets the repository for a class.
111      *
112      * @param string $className
113      * @return \Doctrine\Common\Persistence\ObjectRepository
114      */
115     function getRepository($className);
116
117     /**
118      * Returns the ClassMetadata descriptor for a class.
119      *
120      * The class name must be the fully-qualified class name without a leading backslash
121      * (as it is returned by get_class($obj)).
122      *
123      * @param string $className
124      * @return \Doctrine\Common\Persistence\Mapping\ClassMetadata
125      */
126     function getClassMetadata($className);
127
128     /**
129      * Gets the metadata factory used to gather the metadata of classes.
130      *
131      * @return \Doctrine\Common\Persistence\Mapping\ClassMetadataFactory
132      */
133     function getMetadataFactory();
134
135     /**
136      * Helper method to initialize a lazy loading proxy or persistent collection.
137      *
138      * This method is a no-op for other objects.
139      *
140      * @param object $obj
141      */
142     function initializeObject($obj);
143
144     /**
145      * Check if the object is part of the current UnitOfWork and therefore
146      * managed.
147      *
148      * @param object $object
149      * @return bool
150      */
151     function contains($object);
152 }