vendor/doctrine/lib/Doctrine/ORM/ORMException.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\ORM;
       
    21 
       
    22 use Exception;
       
    23 
       
    24 /**
       
    25  * Base exception class for all ORM exceptions.
       
    26  *
       
    27  * @author Roman Borschel <roman@code-factory.org>
       
    28  * @since 2.0
       
    29  */
       
    30 class ORMException extends Exception
       
    31 {
       
    32     public static function missingMappingDriverImpl()
       
    33     {
       
    34         return new self("It's a requirement to specify a Metadata Driver and pass it ".
       
    35             "to Doctrine\ORM\Configuration::setMetadataDriverImpl().");
       
    36     }
       
    37     
       
    38     public static function entityMissingForeignAssignedId($entity, $relatedEntity)
       
    39     {
       
    40         return new self(
       
    41             "Entity of type " . get_class($entity) . " has identity through a foreign entity " . get_class($relatedEntity) . ", " .
       
    42             "however this entity has no ientity itself. You have to call EntityManager#persist() on the related entity " .
       
    43             "and make sure it an identifier was generated before trying to persist '" . get_class($entity) . "'. In case " .
       
    44             "of Post Insert ID Generation (such as MySQL Auto-Increment or PostgreSQL SERIAL) this means you have to call " .
       
    45             "EntityManager#flush() between both persist operations."
       
    46         );
       
    47     }
       
    48 
       
    49     public static function entityMissingAssignedId($entity)
       
    50     {
       
    51         return new self("Entity of type " . get_class($entity) . " is missing an assigned ID. " .
       
    52             "The identifier generation strategy for this entity requires the ID field to be populated before ".
       
    53             "EntityManager#persist() is called. If you want automatically generated identifiers instead " . 
       
    54             "you need to adjust the metadata mapping accordingly."
       
    55         );
       
    56     }
       
    57 
       
    58     public static function unrecognizedField($field)
       
    59     {
       
    60         return new self("Unrecognized field: $field");
       
    61     }
       
    62 
       
    63     public static function invalidFlushMode($mode)
       
    64     {
       
    65         return new self("'$mode' is an invalid flush mode.");
       
    66     }
       
    67 
       
    68     public static function entityManagerClosed()
       
    69     {
       
    70         return new self("The EntityManager is closed.");
       
    71     }
       
    72 
       
    73     public static function invalidHydrationMode($mode)
       
    74     {
       
    75         return new self("'$mode' is an invalid hydration mode.");
       
    76     }
       
    77 
       
    78     public static function mismatchedEventManager()
       
    79     {
       
    80         return new self("Cannot use different EventManager instances for EntityManager and Connection.");
       
    81     }
       
    82 
       
    83     public static function findByRequiresParameter($methodName)
       
    84     {
       
    85         return new self("You need to pass a parameter to '".$methodName."'");
       
    86     }
       
    87 
       
    88     public static function invalidFindByCall($entityName, $fieldName, $method)
       
    89     {
       
    90         return new self(
       
    91             "Entity '".$entityName."' has no field '".$fieldName."'. ".
       
    92             "You can therefore not call '".$method."' on the entities' repository"
       
    93         );
       
    94     }
       
    95 
       
    96     public static function invalidFindByInverseAssociation($entityName, $associationFieldName)
       
    97     {
       
    98         return new self(
       
    99             "You cannot search for the association field '".$entityName."#".$associationFieldName."', ".
       
   100             "because it is the inverse side of an association. Find methods only work on owning side associations."
       
   101         );
       
   102     }
       
   103 
       
   104     public static function invalidResultCacheDriver() {
       
   105         return new self("Invalid result cache driver; it must implement \Doctrine\Common\Cache\Cache.");
       
   106     }
       
   107 
       
   108     public static function notSupported() {
       
   109         return new self("This behaviour is (currently) not supported by Doctrine 2");
       
   110     }
       
   111 
       
   112     public static function queryCacheNotConfigured()
       
   113     {
       
   114         return new self('Query Cache is not configured.');
       
   115     }
       
   116 
       
   117     public static function metadataCacheNotConfigured()
       
   118     {
       
   119         return new self('Class Metadata Cache is not configured.');
       
   120     }
       
   121 
       
   122     public static function proxyClassesAlwaysRegenerating()
       
   123     {
       
   124         return new self('Proxy Classes are always regenerating.');
       
   125     }
       
   126 
       
   127     public static function unknownEntityNamespace($entityNamespaceAlias)
       
   128     {
       
   129         return new self(
       
   130             "Unknown Entity namespace alias '$entityNamespaceAlias'."
       
   131         );
       
   132     }
       
   133 }