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