vendor/doctrine-common/lib/Doctrine/Common/Persistence/ObjectManager.php
changeset 0 7f95f8617b0b
equal deleted inserted replaced
-1:000000000000 0:7f95f8617b0b
       
     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 LGPL. 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     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     public 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     public 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      */
       
    72     public function merge($object);
       
    73 
       
    74     /**
       
    75      * Detaches an object from the ObjectManager, causing a managed object to
       
    76      * become detached. Unflushed changes made to the object if any
       
    77      * (including removal of the object), will not be synchronized to the database.
       
    78      * Objects which previously referenced the detached object will continue to
       
    79      * reference it.
       
    80      *
       
    81      * @param object $object The object to detach.
       
    82      */
       
    83     public function detach($object);
       
    84 
       
    85     /**
       
    86      * Refreshes the persistent state of an object from the database,
       
    87      * overriding any local changes that have not yet been persisted.
       
    88      *
       
    89      * @param object $object The object to refresh.
       
    90      */
       
    91     public function refresh($object);
       
    92 
       
    93     /**
       
    94      * Flushes all changes to objects that have been queued up to now to the database.
       
    95      * This effectively synchronizes the in-memory state of managed objects with the
       
    96      * database.
       
    97      */
       
    98     public function flush();
       
    99 
       
   100     /**
       
   101      * Gets the repository for a class.
       
   102      *
       
   103      * @param string $className
       
   104      * @return \Doctrine\Common\Persistence\ObjectRepository
       
   105      */
       
   106     public function getRepository($className);
       
   107 
       
   108     /**
       
   109      * Returns the ClassMetadata descriptor for a class.
       
   110      *
       
   111      * The class name must be the fully-qualified class name without a leading backslash
       
   112      * (as it is returned by get_class($obj)).
       
   113      *
       
   114      * @param string $className
       
   115      * @return \Doctrine\Common\Persistence\Mapping\ClassMetadata
       
   116      */
       
   117     public function getClassMetadata($className);
       
   118 
       
   119     /**
       
   120      * Gets the metadata factory used to gather the metadata of classes.
       
   121      *
       
   122      * @return Doctrine\Common\Persistence\Mapping\ClassMetadataFactory
       
   123      */
       
   124     public function getMetadataFactory();
       
   125 }