comparison vendor/doctrine/common/lib/Doctrine/Common/Persistence/ObjectManager.php @ 0:4c8ae668cc8c

Initial import (non-working)
author Chris Cannam
date Wed, 29 Nov 2017 16:09:58 +0000
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:4c8ae668cc8c
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 * @link www.doctrine-project.org
26 * @since 2.1
27 * @author Benjamin Eberlei <kontakt@beberlei.de>
28 * @author Jonathan Wage <jonwage@gmail.com>
29 */
30 interface ObjectManager
31 {
32 /**
33 * Finds an object by its identifier.
34 *
35 * This is just a convenient shortcut for getRepository($className)->find($id).
36 *
37 * @param string $className The class name of the object to find.
38 * @param mixed $id The identity of the object to find.
39 *
40 * @return object The found object.
41 */
42 public 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 * @return void
55 */
56 public function persist($object);
57
58 /**
59 * Removes an object instance.
60 *
61 * A removed object will be removed from the database as a result of the flush operation.
62 *
63 * @param object $object The object instance to remove.
64 *
65 * @return void
66 */
67 public function remove($object);
68
69 /**
70 * Merges the state of a detached object into the persistence context
71 * of this ObjectManager and returns the managed copy of the object.
72 * The object passed to merge will not become associated/managed with this ObjectManager.
73 *
74 * @param object $object
75 *
76 * @return object
77 */
78 public function merge($object);
79
80 /**
81 * Clears the ObjectManager. All objects that are currently managed
82 * by this ObjectManager become detached.
83 *
84 * @param string|null $objectName if given, only objects of this type will get detached.
85 *
86 * @return void
87 */
88 public function clear($objectName = null);
89
90 /**
91 * Detaches an object from the ObjectManager, causing a managed object to
92 * become detached. Unflushed changes made to the object if any
93 * (including removal of the object), will not be synchronized to the database.
94 * Objects which previously referenced the detached object will continue to
95 * reference it.
96 *
97 * @param object $object The object to detach.
98 *
99 * @return void
100 */
101 public function detach($object);
102
103 /**
104 * Refreshes the persistent state of an object from the database,
105 * overriding any local changes that have not yet been persisted.
106 *
107 * @param object $object The object to refresh.
108 *
109 * @return void
110 */
111 public function refresh($object);
112
113 /**
114 * Flushes all changes to objects that have been queued up to now to the database.
115 * This effectively synchronizes the in-memory state of managed objects with the
116 * database.
117 *
118 * @return void
119 */
120 public function flush();
121
122 /**
123 * Gets the repository for a class.
124 *
125 * @param string $className
126 *
127 * @return \Doctrine\Common\Persistence\ObjectRepository
128 */
129 public function getRepository($className);
130
131 /**
132 * Returns the ClassMetadata descriptor for a class.
133 *
134 * The class name must be the fully-qualified class name without a leading backslash
135 * (as it is returned by get_class($obj)).
136 *
137 * @param string $className
138 *
139 * @return \Doctrine\Common\Persistence\Mapping\ClassMetadata
140 */
141 public function getClassMetadata($className);
142
143 /**
144 * Gets the metadata factory used to gather the metadata of classes.
145 *
146 * @return \Doctrine\Common\Persistence\Mapping\ClassMetadataFactory
147 */
148 public function getMetadataFactory();
149
150 /**
151 * Helper method to initialize a lazy loading proxy or persistent collection.
152 *
153 * This method is a no-op for other objects.
154 *
155 * @param object $obj
156 *
157 * @return void
158 */
159 public function initializeObject($obj);
160
161 /**
162 * Checks if the object is part of the current UnitOfWork and therefore managed.
163 *
164 * @param object $object
165 *
166 * @return bool
167 */
168 public function contains($object);
169 }