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
* @link www.doctrine-project.org
27
* @author Benjamin Eberlei <kontakt@beberlei.de>
28
* @author Jonathan Wage <jonwage@gmail.com>
30
interface ObjectManager
33
* Finds an object by its identifier.
35
* This is just a convenient shortcut for getRepository($className)->find($id).
37
* @param string $className The class name of the object to find.
38
* @param mixed $id The identity of the object to find.
40
* @return object The found object.
42
public 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.
56
public function persist($object);
59
* Removes an object instance.
61
* A removed object will be removed from the database as a result of the flush operation.
63
* @param object $object The object instance to remove.
67
public function remove($object);
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.
74
* @param object $object
78
public function merge($object);
81
* Clears the ObjectManager. All objects that are currently managed
82
* by this ObjectManager become detached.
84
* @param string|null $objectName if given, only objects of this type will get detached.
88
public function clear($objectName = null);
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
97
* @param object $object The object to detach.
101
public function detach($object);
104
* Refreshes the persistent state of an object from the database,
105
* overriding any local changes that have not yet been persisted.
107
* @param object $object The object to refresh.
111
public function refresh($object);
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
120
public function flush();
123
* Gets the repository for a class.
125
* @param string $className
127
* @return \Doctrine\Common\Persistence\ObjectRepository
129
public function getRepository($className);
132
* Returns the ClassMetadata descriptor for a class.
134
* The class name must be the fully-qualified class name without a leading backslash
135
* (as it is returned by get_class($obj)).
137
* @param string $className
139
* @return \Doctrine\Common\Persistence\Mapping\ClassMetadata
141
public function getClassMetadata($className);
144
* Gets the metadata factory used to gather the metadata of classes.
146
* @return \Doctrine\Common\Persistence\Mapping\ClassMetadataFactory
148
public function getMetadataFactory();
151
* Helper method to initialize a lazy loading proxy or persistent collection.
153
* This method is a no-op for other objects.
159
public function initializeObject($obj);
162
* Checks if the object is part of the current UnitOfWork and therefore managed.
164
* @param object $object
168
public function contains($object);