2008-07-11 14:48:04 +04:00
< ? php
2008-08-24 23:27:24 +04:00
/*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
* " AS IS " AND ANY EXPRESS OR IMPLIED WARRANTIES , INCLUDING , BUT NOT
* LIMITED TO , THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
* A PARTICULAR PURPOSE ARE DISCLAIMED . IN NO EVENT SHALL THE COPYRIGHT
* OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT , INDIRECT , INCIDENTAL ,
* SPECIAL , EXEMPLARY , OR CONSEQUENTIAL DAMAGES ( INCLUDING , BUT NOT
* LIMITED TO , PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES ; LOSS OF USE ,
* DATA , OR PROFITS ; OR BUSINESS INTERRUPTION ) HOWEVER CAUSED AND ON ANY
* THEORY OF LIABILITY , WHETHER IN CONTRACT , STRICT LIABILITY , OR TORT
* ( INCLUDING NEGLIGENCE OR OTHERWISE ) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE , EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE .
*
* This software consists of voluntary contributions made by many individuals
2012-05-26 16:37:00 +04:00
* and is licensed under the MIT license . For more information , see
2008-08-24 23:27:24 +04:00
* < http :// www . phpdoctrine . org >.
*/
2009-02-07 20:02:13 +03:00
namespace Doctrine\ORM\Mapping ;
2008-07-11 14:48:04 +04:00
/**
* A MappingException indicates that something is wrong with the mapping setup .
*
* @ since 2.0
*/
2010-01-22 01:26:36 +03:00
class MappingException extends \Doctrine\ORM\ORMException
2008-07-11 14:48:04 +04:00
{
2012-12-03 13:36:08 +04:00
/**
* @ return MappingException
*/
2010-04-10 19:35:18 +04:00
public static function pathRequired ()
{
return new self ( " Specifying the paths to your entities is required " .
" in the AnnotationDriver to retrieve all class names. " );
}
2012-12-03 13:36:08 +04:00
/**
* @ param string $entityName
*
* @ return MappingException
*/
2008-07-11 14:48:04 +04:00
public static function identifierRequired ( $entityName )
{
2012-10-16 08:04:25 +04:00
if ( false !== ( $parent = get_parent_class ( $entityName ))) {
2012-03-25 19:54:09 +04:00
return new self ( sprintf (
2012-03-26 08:03:32 +04:00
'No identifier/primary key specified for Entity "%s" sub class of "%s". Every Entity must have an identifier/primary key.' ,
2012-03-25 20:34:52 +04:00
$entityName , $parent
2012-03-25 19:54:09 +04:00
));
}
return new self ( sprintf (
'No identifier/primary key specified for Entity "%s". Every Entity must have an identifier/primary key.' ,
$entityName
));
2008-07-11 14:48:04 +04:00
}
2010-02-23 17:02:31 +03:00
2012-12-03 13:36:08 +04:00
/**
* @ param string $entityName
* @ param string $type
*
* @ return MappingException
*/
2010-02-26 00:16:05 +03:00
public static function invalidInheritanceType ( $entityName , $type )
2008-07-21 00:13:24 +04:00
{
2010-02-26 00:16:05 +03:00
return new self ( " The inheritance type ' $type ' specified for ' $entityName ' does not exist. " );
2008-07-21 00:13:24 +04:00
}
2010-02-23 17:02:31 +03:00
2012-12-03 13:36:08 +04:00
/**
* @ return MappingException
*/
2008-07-21 00:13:24 +04:00
public static function generatorNotAllowedWithCompositeId ()
{
return new self ( " Id generators can't be used with a composite id. " );
}
2010-02-23 17:02:31 +03:00
2012-12-03 13:36:08 +04:00
/**
* @ param string $entity
*
* @ return MappingException
*/
2011-01-23 16:20:15 +03:00
public static function missingFieldName ( $entity )
2008-08-16 23:40:59 +04:00
{
2011-01-23 16:20:15 +03:00
return new self ( " The field or association mapping misses the 'fieldName' attribute in entity ' $entity '. " );
2008-08-16 23:40:59 +04:00
}
2010-02-23 17:02:31 +03:00
2012-12-03 13:36:08 +04:00
/**
* @ param string $fieldName
*
* @ return MappingException
*/
2008-08-16 23:40:59 +04:00
public static function missingTargetEntity ( $fieldName )
{
return new self ( " The association mapping ' $fieldName ' misses the 'targetEntity' attribute. " );
}
2010-02-23 17:02:31 +03:00
2012-12-03 13:36:08 +04:00
/**
* @ param string $fieldName
*
* @ return MappingException
*/
2008-08-16 23:40:59 +04:00
public static function missingSourceEntity ( $fieldName )
{
return new self ( " The association mapping ' $fieldName ' misses the 'sourceEntity' attribute. " );
}
2010-02-23 17:02:31 +03:00
2012-12-03 13:36:08 +04:00
/**
* @ param string $entityName
* @ param string $fileName
*
* @ return MappingException
*/
2010-02-26 00:36:48 +03:00
public static function mappingFileNotFound ( $entityName , $fileName )
2010-01-28 15:46:12 +03:00
{
2010-02-26 00:36:48 +03:00
return new self ( " No mapping file found named ' $fileName ' for class ' $entityName '. " );
2010-01-28 15:46:12 +03:00
}
2011-12-20 01:56:19 +04:00
2012-12-03 13:36:08 +04:00
/**
2012-02-02 06:57:39 +04:00
* Exception for invalid property name override .
*
2012-12-03 13:36:08 +04:00
* @ param string $className The entity ' s name .
2012-02-02 06:57:39 +04:00
* @ param string $fieldName
2012-12-03 13:36:08 +04:00
*
* @ return MappingException
2012-02-02 06:57:39 +04:00
*/
public static function invalidOverrideFieldName ( $className , $fieldName )
{
return new self ( " Invalid field override named ' $fieldName ' for class ' $className '. " );
}
2012-04-14 09:10:44 +04:00
/**
* Exception for invalid property type override .
*
2012-12-03 13:36:08 +04:00
* @ param string $className The entity ' s name .
2012-04-14 09:10:44 +04:00
* @ param string $fieldName
2012-12-03 13:36:08 +04:00
*
* @ return MappingException
2012-04-14 09:10:44 +04:00
*/
public static function invalidOverrideFieldType ( $className , $fieldName )
{
return new self ( " The column type of attribute ' $fieldName ' on class ' $className ' could not be changed. " );
}
2012-12-03 13:36:08 +04:00
/**
* @ param string $className
* @ param string $fieldName
*
* @ return MappingException
*/
2010-12-22 02:17:50 +03:00
public static function mappingNotFound ( $className , $fieldName )
2008-08-16 23:40:59 +04:00
{
2010-12-22 02:17:50 +03:00
return new self ( " No mapping found for field ' $fieldName ' on class ' $className '. " );
2008-08-16 23:40:59 +04:00
}
2010-02-23 17:02:31 +03:00
2012-12-03 13:36:08 +04:00
/**
* @ param string $className
* @ param string $queryName
*
* @ return MappingException
*/
2011-03-07 00:45:09 +03:00
public static function queryNotFound ( $className , $queryName )
{
return new self ( " No query found named ' $queryName ' on class ' $className '. " );
}
2012-12-03 13:36:08 +04:00
/**
* @ param string $className
* @ param string $resultName
*
* @ return MappingException
*/
2012-02-26 07:16:54 +04:00
public static function resultMappingNotFound ( $className , $resultName )
{
return new self ( " No result set mapping found named ' $resultName ' on class ' $className '. " );
}
2012-12-03 13:36:08 +04:00
/**
* @ param string $entity
* @ param string $queryName
*
* @ return MappingException
*/
2012-02-26 05:13:46 +04:00
public static function emptyQueryMapping ( $entity , $queryName )
{
return new self ( 'Query named "' . $queryName . '" in "' . $entity . '" could not be empty.' );
}
2012-12-03 13:36:08 +04:00
/**
* @ param string $className
*
* @ return MappingException
*/
2012-02-26 07:16:54 +04:00
public static function nameIsMandatoryForQueryMapping ( $className )
2012-02-26 05:13:46 +04:00
{
return new self ( " Query name on entity class ' $className ' is not defined. " );
}
2012-12-03 13:36:08 +04:00
/**
* @ param string $entity
* @ param string $queryName
*
* @ return MappingException
*/
2012-02-26 05:13:46 +04:00
public static function missingQueryMapping ( $entity , $queryName )
{
return new self ( 'Query named "' . $queryName . '" in "' . $entity . ' requires a result class or result set mapping.' );
}
2012-12-03 13:36:08 +04:00
/**
* @ param string $entity
* @ param string $resultName
*
* @ return MappingException
*/
2012-02-26 07:16:54 +04:00
public static function missingResultSetMappingEntity ( $entity , $resultName )
{
return new self ( 'Result set mapping named "' . $resultName . '" in "' . $entity . ' requires a entity class name.' );
}
2012-02-28 06:46:27 +04:00
2012-12-03 13:36:08 +04:00
/**
* @ param string $entity
* @ param string $resultName
*
* @ return MappingException
*/
2012-02-28 06:46:27 +04:00
public static function missingResultSetMappingFieldName ( $entity , $resultName )
{
return new self ( 'Result set mapping named "' . $resultName . '" in "' . $entity . ' requires a field name.' );
}
2012-01-17 18:39:52 +04:00
2012-12-03 13:36:08 +04:00
/**
* @ param string $className
*
* @ return MappingException
*/
2012-02-26 07:16:54 +04:00
public static function nameIsMandatoryForSqlResultSetMapping ( $className )
{
return new self ( " Result set mapping name on entity class ' $className ' is not defined. " );
}
2012-12-03 13:36:08 +04:00
/**
* @ param string $fieldName
*
* @ return MappingException
*/
2008-08-22 13:37:03 +04:00
public static function oneToManyRequiresMappedBy ( $fieldName )
{
return new self ( " OneToMany mapping on field ' $fieldName ' requires the 'mappedBy' attribute. " );
}
2010-02-23 17:02:31 +03:00
2012-12-03 13:36:08 +04:00
/**
* @ param string $fieldName
*
* @ return MappingException
*/
2008-08-24 23:27:24 +04:00
public static function joinTableRequired ( $fieldName )
{
return new self ( " The mapping of field ' $fieldName ' requires an the 'joinTable' attribute. " );
}
2010-02-23 17:02:31 +03:00
2010-01-14 18:48:42 +03:00
/**
* Called if a required option was not found but is required
2010-02-23 17:02:31 +03:00
*
2012-12-03 13:36:08 +04:00
* @ param string $field Which field cannot be processed ?
* @ param string $expectedOption Which option is required
* @ param string $hint Can optionally be used to supply a tip for common mistakes ,
* e . g . " Did you think of the plural s? "
*
2010-02-23 17:02:31 +03:00
* @ return MappingException
2010-01-14 18:48:42 +03:00
*/
2010-02-23 17:02:31 +03:00
static function missingRequiredOption ( $field , $expectedOption , $hint = '' )
2010-01-14 18:48:42 +03:00
{
$message = " The mapping of field ' { $field } ' is invalid: The option ' { $expectedOption } ' is required. " ;
if ( ! empty ( $hint )) {
$message .= ' (Hint: ' . $hint . ')' ;
}
return new self ( $message );
}
2010-02-23 17:02:31 +03:00
2008-08-24 23:27:24 +04:00
/**
* Generic exception for invalid mappings .
*
* @ param string $fieldName
2012-12-03 13:36:08 +04:00
*
* @ return MappingException
2008-08-24 23:27:24 +04:00
*/
public static function invalidMapping ( $fieldName )
{
return new self ( " The mapping of field ' $fieldName ' is invalid. " );
}
2010-02-23 17:02:31 +03:00
2010-01-21 22:52:17 +03:00
/**
* Exception for reflection exceptions - adds the entity name ,
* because there might be long classnames that will be shortened
* within the stacktrace
2010-02-23 17:02:31 +03:00
*
2012-12-03 13:36:08 +04:00
* @ param string $entity The entity ' s name
2010-01-21 22:52:17 +03:00
* @ param \ReflectionException $previousException
2012-12-03 13:36:08 +04:00
*
* @ return MappingException
2010-01-21 22:52:17 +03:00
*/
2010-01-22 01:26:36 +03:00
public static function reflectionFailure ( $entity , \ReflectionException $previousException )
{
return new self ( 'An error occurred in ' . $entity , 0 , $previousException );
2010-01-21 22:52:17 +03:00
}
2010-02-23 17:02:31 +03:00
2012-12-03 13:36:08 +04:00
/**
* @ param string $className
* @ param string $joinColumn
*
* @ return MappingException
*/
2010-01-30 00:24:29 +03:00
public static function joinColumnMustPointToMappedField ( $className , $joinColumn )
{
return new self ( 'The column ' . $joinColumn . ' must be mapped to a field in class '
. $className . ' since it is referenced by a join column of another class.' );
}
2010-02-03 00:17:00 +03:00
2012-12-03 13:36:08 +04:00
/**
* @ param string $className
*
* @ return MappingException
*/
2010-02-03 00:17:00 +03:00
public static function classIsNotAValidEntityOrMappedSuperClass ( $className )
{
2012-10-16 08:04:25 +04:00
if ( false !== ( $parent = get_parent_class ( $className ))) {
2012-03-25 19:54:09 +04:00
return new self ( sprintf (
2012-03-26 08:03:32 +04:00
'Class "%s" sub class of "%s" is not a valid entity or mapped super class.' ,
2012-03-25 19:54:09 +04:00
$className , $parent
));
}
return new self ( sprintf (
'Class "%s" is not a valid entity or mapped super class.' ,
$className
));
2010-02-03 00:17:00 +03:00
}
2012-12-03 13:36:08 +04:00
/**
* @ param string $className
* @ param string $propertyName
*
* @ return MappingException
*/
2010-02-03 00:17:00 +03:00
public static function propertyTypeIsRequired ( $className , $propertyName )
{
return new self ( " The attribute 'type' is required for the column description of property " . $className . " :: \$ " . $propertyName . " . " );
}
2012-12-03 13:36:08 +04:00
/**
* @ param string $className
*
* @ return MappingException
*/
2010-02-03 00:17:00 +03:00
public static function tableIdGeneratorNotImplemented ( $className )
{
return new self ( " TableIdGenerator is not yet implemented for use with class " . $className );
}
/**
2012-12-03 13:36:08 +04:00
* @ param string $entity The entity ' s name .
* @ param string $fieldName The name of the field that was already declared .
*
* @ return MappingException
2010-02-03 00:17:00 +03:00
*/
2012-02-26 05:13:46 +04:00
public static function duplicateFieldMapping ( $entity , $fieldName )
{
2010-02-03 00:17:00 +03:00
return new self ( 'Property "' . $fieldName . '" in "' . $entity . '" was already declared, but it must be declared only once' );
}
2012-12-03 13:36:08 +04:00
/**
* @ param string $entity
* @ param string $fieldName
*
* @ return MappingException
*/
2012-02-26 05:13:46 +04:00
public static function duplicateAssociationMapping ( $entity , $fieldName )
{
2010-02-03 00:46:39 +03:00
return new self ( 'Property "' . $fieldName . '" in "' . $entity . '" was already declared, but it must be declared only once' );
}
2012-12-03 13:36:08 +04:00
/**
* @ param string $entity
* @ param string $queryName
*
* @ return MappingException
*/
2012-02-26 05:13:46 +04:00
public static function duplicateQueryMapping ( $entity , $queryName )
{
2011-03-07 00:45:09 +03:00
return new self ( 'Query named "' . $queryName . '" in "' . $entity . '" was already declared, but it must be declared only once' );
}
2012-12-03 13:36:08 +04:00
/**
* @ param string $entity
* @ param string $resultName
*
* @ return MappingException
*/
2012-02-26 07:16:54 +04:00
public static function duplicateResultSetMapping ( $entity , $resultName )
{
return new self ( 'Result set mapping named "' . $resultName . '" in "' . $entity . '" was already declared, but it must be declared only once' );
}
2012-12-03 13:36:08 +04:00
/**
* @ param string $entity
*
* @ return MappingException
*/
2012-02-26 05:13:46 +04:00
public static function singleIdNotAllowedOnCompositePrimaryKey ( $entity )
{
2010-02-03 00:17:00 +03:00
return new self ( 'Single id is not allowed on composite primary key in entity ' . $entity );
}
2012-12-03 13:36:08 +04:00
/**
* @ param string $entity
* @ param string $fieldName
* @ param string $unsupportedType
*
* @ return MappingException
*/
2012-02-26 05:13:46 +04:00
public static function unsupportedOptimisticLockingType ( $entity , $fieldName , $unsupportedType )
{
2010-02-03 00:17:00 +03:00
return new self ( 'Locking type "' . $unsupportedType . '" (specified in "' . $entity . '", field "' . $fieldName . '") '
. 'is not supported by Doctrine.'
);
}
2010-02-23 17:02:31 +03:00
2012-12-03 13:36:08 +04:00
/**
* @ param string | null $path
*
* @ return MappingException
*/
2010-09-15 23:14:15 +04:00
public static function fileMappingDriversRequireConfiguredDirectoryPath ( $path = null )
2010-01-31 00:11:13 +03:00
{
2010-09-15 23:14:15 +04:00
if ( ! empty ( $path )) {
$path = '[' . $path . ']' ;
}
2011-11-18 21:33:03 +04:00
2010-09-15 23:14:15 +04:00
return new self (
'File mapping drivers must have a valid directory path, ' .
'however the given path ' . $path . ' seems to be incorrect!'
);
2010-01-31 00:11:13 +03:00
}
2010-02-23 17:02:31 +03:00
/**
2012-12-03 13:36:08 +04:00
* Returns an exception that indicates that a class used in a discriminator map does not exist .
2010-02-23 17:02:31 +03:00
* An example would be an outdated ( maybe renamed ) classname .
*
2012-12-03 13:36:08 +04:00
* @ param string $className The class that could not be found
2010-02-23 17:02:31 +03:00
* @ param string $owningClass The class that declares the discriminator map .
2012-12-03 13:36:08 +04:00
*
* @ return MappingException
2010-02-23 17:02:31 +03:00
*/
2012-02-26 05:13:46 +04:00
public static function invalidClassInDiscriminatorMap ( $className , $owningClass )
{
2010-02-23 17:02:31 +03:00
return new self (
" Entity class ' $className ' used in the discriminator map of class ' $owningClass ' " .
" does not exist. "
);
}
2010-03-20 22:19:12 +03:00
2012-12-03 13:36:08 +04:00
/**
* @ param string $className
* @ param array $entries
* @ param array $map
*
* @ return MappingException
*/
2012-05-05 01:15:12 +04:00
public static function duplicateDiscriminatorEntry ( $className , array $entries , array $map )
{
return new self (
" The entries " . implode ( ', ' , $entries ) . " in discriminator map of class ' " . $className . " ' is duplicated. " .
" If the discriminator map is automatically generated you have to convert it to an explicit discriminator map now. " .
" The entries of the current map are: @DiscriminatorMap( { " . implode ( ', ' , array_map (
function ( $a , $b ) { return " ' $a ': ' $b ' " ; }, array_keys ( $map ), array_values ( $map )
)) . " }) "
);
}
2012-12-03 13:36:08 +04:00
/**
* @ param string $className
*
* @ return MappingException
*/
2010-08-08 14:29:14 +04:00
public static function missingDiscriminatorMap ( $className )
{
return new self ( " Entity class ' $className ' is using inheritance but no discriminator map was defined. " );
}
2012-12-03 13:36:08 +04:00
/**
* @ param string $className
*
* @ return MappingException
*/
2010-08-08 14:29:14 +04:00
public static function missingDiscriminatorColumn ( $className )
{
return new self ( " Entity class ' $className ' is using inheritance but no discriminator column was defined. " );
}
2012-12-03 13:36:08 +04:00
/**
* @ param string $className
* @ param string $type
*
* @ return MappingException
*/
2010-11-11 23:13:03 +03:00
public static function invalidDiscriminatorColumnType ( $className , $type )
{
return new self ( " Discriminator column type on entity class ' $className ' is not allowed to be ' $type '. 'string' or 'integer' type variables are suggested! " );
}
2012-12-03 13:36:08 +04:00
/**
* @ param string $className
*
* @ return MappingException
*/
2012-02-14 05:38:36 +04:00
public static function nameIsMandatoryForDiscriminatorColumns ( $className )
{
return new self ( " Discriminator column name on entity class ' $className ' is not defined. " );
}
2012-12-03 13:36:08 +04:00
/**
* @ param string $className
* @ param string $fieldName
*
* @ return MappingException
*/
2010-11-11 23:21:17 +03:00
public static function cannotVersionIdField ( $className , $fieldName )
{
2013-03-11 04:08:58 +04:00
return new self ( " Setting Id field ' $fieldName ' as versionable in entity class ' $className ' is not supported. " );
2010-11-11 23:21:17 +03:00
}
2012-12-03 13:36:08 +04:00
/**
* @ param string $className
* @ param string $fieldName
* @ param string $type
*
* @ return MappingException
*/
2011-11-20 22:50:51 +04:00
public static function sqlConversionNotAllowedForIdentifiers ( $className , $fieldName , $type )
{
return new self ( " It is not possible to set id field ' $fieldName ' to type ' $type ' in entity class ' $className '. The type ' $type ' requires conversion SQL which is not allowed for identifiers. " );
}
2010-03-20 22:19:12 +03:00
/**
2012-12-03 13:36:08 +04:00
* @ param string $className
* @ param string $columnName
*
* @ return MappingException
2010-03-20 22:19:12 +03:00
*/
public static function duplicateColumnName ( $className , $columnName )
{
return new self ( " Duplicate definition of column ' " . $columnName . " ' on entity ' " . $className . " ' in a field or discriminator column mapping. " );
}
2010-11-11 23:13:03 +03:00
2012-12-03 13:36:08 +04:00
/**
* @ param string $className
* @ param string $field
*
* @ return MappingException
*/
2013-03-11 04:08:58 +04:00
public static function illegalToManyAssociationOnMappedSuperclass ( $className , $field )
2010-12-28 13:59:51 +03:00
{
2010-12-31 16:39:01 +03:00
return new self ( " It is illegal to put an inverse side one-to-many or many-to-many association on mapped superclass ' " . $className . " # " . $field . " '. " );
2010-12-28 13:59:51 +03:00
}
2010-12-29 03:02:21 +03:00
/**
* @ param string $className
* @ param string $targetEntity
* @ param string $targetField
2012-12-03 13:36:08 +04:00
*
* @ return MappingException
2010-12-29 03:02:21 +03:00
*/
public static function cannotMapCompositePrimaryKeyEntitiesAsForeignId ( $className , $targetEntity , $targetField )
{
return new self ( " It is not possible to map entity ' " . $className . " ' with a composite primary key " .
" as part of the primary key of another entity ' " . $targetEntity . " # " . $targetField . " '. " );
}
2011-01-01 20:17:19 +03:00
2012-12-03 13:36:08 +04:00
/**
* @ param string $className
* @ param string $field
*
* @ return MappingException
*/
2011-01-01 20:17:19 +03:00
public static function noSingleAssociationJoinColumnFound ( $className , $field )
{
return new self ( " ' $className # $field ' is not an association with a single join column. " );
}
2012-12-03 13:36:08 +04:00
/**
* @ param string $className
* @ param string $column
*
* @ return MappingException
*/
2011-01-01 20:17:19 +03:00
public static function noFieldNameFoundForColumn ( $className , $column )
{
return new self ( " Cannot find a field on ' $className ' that is mapped to column ' $column '. Either the " .
" field does not exist or an association exists but it has multiple join columns. " );
}
2012-12-03 13:36:08 +04:00
/**
* @ param string $className
* @ param string $field
*
* @ return MappingException
*/
2011-01-01 20:17:19 +03:00
public static function illegalOrphanRemovalOnIdentifierAssociation ( $className , $field )
{
return new self ( " The orphan removal option is not allowed on an association that is " .
" part of the identifier in ' $className # $field '. " );
}
2012-12-03 13:36:08 +04:00
/**
* @ param string $className
* @ param string $field
*
* @ return MappingException
*/
2011-11-18 21:33:03 +04:00
public static function illegalOrphanRemoval ( $className , $field )
{
return new self ( " Orphan removal is only allowed on one-to-one and one-to-many " .
" associations, but " . $className . " # " . $field . " is not. " );
}
2012-12-03 13:36:08 +04:00
/**
* @ param string $className
* @ param string $field
*
* @ return MappingException
*/
2013-03-11 04:08:58 +04:00
public static function illegalInverseIdentifierAssociation ( $className , $field )
2011-01-01 20:17:19 +03:00
{
return new self ( " An inverse association is not allowed to be identifier in ' $className # $field '. " );
}
2012-12-03 13:36:08 +04:00
/**
* @ param string $className
* @ param string $field
*
* @ return MappingException
*/
2013-03-11 04:08:58 +04:00
public static function illegalToManyIdentifierAssociation ( $className , $field )
2011-01-01 20:17:19 +03:00
{
return new self ( " Many-to-many or one-to-many associations are not allowed to be identifier in ' $className # $field '. " );
}
2011-11-18 21:33:03 +04:00
2012-12-03 13:36:08 +04:00
/**
* @ param string $className
*
* @ return MappingException
*/
2011-03-04 00:51:53 +03:00
public static function noInheritanceOnMappedSuperClass ( $className )
{
return new self ( " Its not supported to define inheritance information on a mapped superclass ' " . $className . " '. " );
}
2011-11-18 21:33:03 +04:00
2012-12-03 13:36:08 +04:00
/**
* @ param string $className
* @ param string $rootClassName
*
* @ return MappingException
*/
2011-06-16 00:27:24 +04:00
public static function mappedClassNotPartOfDiscriminatorMap ( $className , $rootClassName )
{
return new self (
2011-10-24 13:01:27 +04:00
" Entity ' " . $className . " ' has to be part of the discriminator map of ' " . $rootClassName . " ' " .
2013-03-11 04:08:58 +04:00
" to be properly mapped in the inheritance hierarchy. Alternatively you can make ' " . $className . " ' an abstract class " .
" to avoid this exception from occurring. "
2011-06-16 00:27:24 +04:00
);
}
2011-09-04 16:13:20 +04:00
2012-12-03 13:36:08 +04:00
/**
* @ param string $className
* @ param string $methodName
*
* @ return MappingException
*/
2011-09-04 16:13:20 +04:00
public static function lifecycleCallbackMethodNotFound ( $className , $methodName )
{
return new self ( " Entity ' " . $className . " ' has no method ' " . $methodName . " ' to be registered as lifecycle callback. " );
}
2011-11-08 13:01:22 +04:00
2012-08-01 05:20:21 +04:00
/**
2013-04-06 18:11:52 +04:00
* @ param string $listenerName
2012-08-01 05:20:21 +04:00
* @ param string $className
*
* @ return \Doctrine\ORM\Mapping\MappingException
*/
public static function entityListenerClassNotFound ( $listenerName , $className )
{
2012-08-12 21:53:00 +04:00
return new self ( sprintf ( 'Entity Listener "%s" declared on "%s" not found.' , $listenerName , $className ));
2012-08-01 05:20:21 +04:00
}
/**
* @ param string $listenerName
* @ param string $methodName
* @ param string $className
*
* @ return \Doctrine\ORM\Mapping\MappingException
*/
public static function entityListenerMethodNotFound ( $listenerName , $methodName , $className )
{
2012-08-12 21:53:00 +04:00
return new self ( sprintf ( 'Entity Listener "%s" declared on "%s" has no method "%s".' , $listenerName , $className , $methodName ));
2012-08-01 05:20:21 +04:00
}
2012-12-03 13:36:08 +04:00
/**
* @ param string $className
* @ param string $annotation
*
* @ return MappingException
*/
2011-11-08 13:01:22 +04:00
public static function invalidFetchMode ( $className , $annotation )
{
return new self ( " Entity ' " . $className . " ' has a mapping with invalid fetch mode ' " . $annotation . " ' " );
}
2011-12-18 03:32:35 +04:00
2012-12-03 13:36:08 +04:00
/**
* @ param string $className
*
* @ return MappingException
*/
2011-12-18 03:32:35 +04:00
public static function compositeKeyAssignedIdGeneratorRequired ( $className )
{
return new self ( " Entity ' " . $className . " ' has a composite identifier but uses an ID generator other than manually assigning (Identity, Sequence). This is not supported. " );
}
2011-12-22 02:56:25 +04:00
2012-12-03 13:36:08 +04:00
/**
* @ param string $targetEntity
* @ param string $sourceEntity
* @ param string $associationName
*
* @ return MappingException
*/
2011-10-15 19:38:55 +04:00
public static function invalidTargetEntityClass ( $targetEntity , $sourceEntity , $associationName )
{
return new self ( " The target-entity " . $targetEntity . " cannot be found in ' " . $sourceEntity . " # " . $associationName . " '. " );
}
2012-04-01 13:01:41 +04:00
2012-12-03 13:36:08 +04:00
/**
* @ param array $cascades
* @ param string $className
* @ param string $propertyName
*
* @ return MappingException
*/
2012-04-05 06:47:23 +04:00
public static function invalidCascadeOption ( array $cascades , $className , $propertyName )
2012-04-01 13:01:41 +04:00
{
$cascades = implode ( " , " , array_map ( function ( $e ) { return " ' " . $e . " ' " ; }, $cascades ));
2012-04-05 06:47:23 +04:00
return new self ( sprintf (
2012-05-04 20:26:17 +04:00
" You have specified invalid cascade options for %s:: $ %s: %s; available options: 'remove', 'persist', 'refresh', 'merge', and 'detach' " ,
2012-04-05 06:47:23 +04:00
$className ,
$propertyName ,
$cascades
));
2012-04-01 13:01:41 +04:00
}
2013-09-08 17:59:39 +04:00
/**
* @ param string $className
*
* @ return MappingException
*/
public static function missingSequenceName ( $className )
{
return new self (
sprintf ( 'Missing "sequenceName" attribute for sequence id generator definition on class "%s".' , $className )
);
}
2011-11-08 13:01:22 +04:00
}