PHP Class Neos\Flow\Persistence\Doctrine\Mapping\Driver\FlowAnnotationDriver

It gives precedence to Doctrine annotations but fills gaps from other info if possible: - Entity.repositoryClass is set to the repository found in the class schema - Table.name is set to a sane value - Column.type is set to property type - *.targetEntity is set to property type If a property is not marked as an association the mapping type is set to "object" for objects.
Inheritance: implements Doctrine\Common\Persistence\Mapping\Driver\MappingDriver, implements Neos\Flow\Aop\Pointcut\PointcutFilterInterface
Mostra file Open project: neos/flow-development-collection

Protected Properties

Property Type Description
$classNames array
$entityManager Doctrine\Common\Persistence\ObjectManager
$reader Doctrine\Common\Annotations\AnnotationReader
$reflectionService Neos\Flow\Reflection\ReflectionService
$tableNameLengthLimit integer

Public Methods

Method Description
__construct ( ) Initializes a new AnnotationDriver that uses the given AnnotationReader for reading docblock annotations.
getAllClassNames ( ) : array Returns the names of all mapped (non-transient) classes known to this driver.
getRuntimeEvaluationsDefinition ( ) : array Returns runtime evaluations for a previously matched pointcut
hasRuntimeEvaluationsDefinition ( ) : boolean Returns TRUE if this filter holds runtime evaluations for a previously matched pointcut
inferTableNameFromClassName ( string $className, integer $lengthLimit = null ) : string Given a class name a table name is returned. That name should be reasonably unique.
injectReflectionService ( ReflectionService $reflectionService ) : void
isTransient ( string $className ) : boolean Returns whether the class with the specified name is transient. Only non-transient classes, that is entities and mapped superclasses, should have their metadata loaded.
loadMetadataForClass ( string $className, Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata ) : void Loads the metadata for the specified class into the provided container.
matches ( string $className, string $methodName, string $methodDeclaringClassName, mixed $pointcutQueryIdentifier ) : boolean Checks if the specified class has a property annotated with Id
reduceTargetClassNames ( ClassNameIndex $classNameIndex ) : ClassNameIndex This method is used to optimize the matching process.
setEntityManager ( Doctrine\Common\Persistence\ObjectManager $entityManager ) : void

Protected Methods

Method Description
addColumnToMappingArray ( Doctrine\ORM\Mapping\Column $columnAnnotation, array $mapping = [], string $fieldName = null ) : array Parse the given Column into an array
buildJoinColumnsIfNeeded ( array $joinColumns, array $mapping, ReflectionProperty $property, integer $direction = self::MAPPING_REGULAR ) : array Check if the referenced column name is set (and valid) and if not make sure it is initialized properly.
buildJoinTableColumnName ( string $className ) : string Build a name for a column in a jointable.
evaluateEntityListenersAnnotation ( ReflectionClass $class, Doctrine\ORM\Mapping\ClassMetadata $metadata, array $classAnnotations ) : void Evaluate the EntityListeners annotation and amend the metadata accordingly.
evaluateJoinColumnAnnotations ( ReflectionProperty $property ) : array Check for and build JoinColummn/JoinColumns annotations.
evaluateJoinTableAnnotation ( Doctrine\ORM\Mapping\JoinTable $joinTableAnnotation, ReflectionProperty $property, string $className, array $mapping ) : array Evaluate JoinTable annotations and fill missing bits as needed.
evaluateLifeCycleAnnotations ( ReflectionClass $class, Doctrine\ORM\Mapping\ClassMetadataInfo $metadata ) : void Evaluate the lifecycle annotations and amend the metadata accordingly.
evaluateOverridesAnnotations ( array $classAnnotations, Doctrine\ORM\Mapping\ClassMetadataInfo $metadata ) : void Evaluate the association overrides annotations and amend the metadata accordingly.
evaluatePropertyAnnotations ( Doctrine\ORM\Mapping\ClassMetadataInfo $metadata ) : void Evaluate the property annotations and amend the metadata accordingly.
getClassSchema ( string $className ) : ClassSchema Fetch a class schema for the given class, if possible.
getMaxIdentifierLength ( ) : integer Derive maximum identifier length from doctrine DBAL
getMethodCallbacks ( ReflectionMethod $method ) : array Returns an array of callbacks for lifecycle annotations on the given method.
getUnproxiedClassName ( string $className ) : string Returns the classname after stripping a potentially present Compiler::ORIGINAL_CLASSNAME_SUFFIX.
inferJoinTableNameFromClassAndPropertyName ( string $className, string $propertyName ) : string Given a class and property name a table name is returned. That name should be reasonably unique.
isAggregateRoot ( string $className, string $propertySourceHint ) : boolean Check for $className being an aggregate root.
isValueObject ( string $className, string $propertySourceHint ) : boolean Check for $className being a value object.
joinColumnToArray ( Doctrine\ORM\Mapping\JoinColumn $joinColumnAnnotation, string $propertyName = null ) : array Parse the given JoinColumn into an array
truncateIdentifier ( string $identifier, integer $lengthLimit = null, string $hashSource = null ) : string Truncate an identifier if needed and append a hash to ensure uniqueness.

Private Methods

Method Description
getFetchMode ( string $className, string $fetchMode ) : integer Attempts to resolve the fetch mode.

Method Details

__construct() public method

Initializes a new AnnotationDriver that uses the given AnnotationReader for reading docblock annotations.
public __construct ( )

addColumnToMappingArray() protected method

Parse the given Column into an array
protected addColumnToMappingArray ( Doctrine\ORM\Mapping\Column $columnAnnotation, array $mapping = [], string $fieldName = null ) : array
$columnAnnotation Doctrine\ORM\Mapping\Column
$mapping array
$fieldName string
return array

buildJoinColumnsIfNeeded() protected method

Check if the referenced column name is set (and valid) and if not make sure it is initialized properly.
protected buildJoinColumnsIfNeeded ( array $joinColumns, array $mapping, ReflectionProperty $property, integer $direction = self::MAPPING_REGULAR ) : array
$joinColumns array
$mapping array
$property ReflectionProperty
$direction integer regular or inverse mapping (use is to be coded)
return array

buildJoinTableColumnName() protected method

Build a name for a column in a jointable.
protected buildJoinTableColumnName ( string $className ) : string
$className string
return string

evaluateEntityListenersAnnotation() protected method

Evaluate the EntityListeners annotation and amend the metadata accordingly.
protected evaluateEntityListenersAnnotation ( ReflectionClass $class, Doctrine\ORM\Mapping\ClassMetadata $metadata, array $classAnnotations ) : void
$class ReflectionClass
$metadata Doctrine\ORM\Mapping\ClassMetadata
$classAnnotations array
return void

evaluateJoinColumnAnnotations() protected method

If no annotations are found, a default is returned.
protected evaluateJoinColumnAnnotations ( ReflectionProperty $property ) : array
$property ReflectionProperty
return array

evaluateJoinTableAnnotation() protected method

Evaluate JoinTable annotations and fill missing bits as needed.
protected evaluateJoinTableAnnotation ( Doctrine\ORM\Mapping\JoinTable $joinTableAnnotation, ReflectionProperty $property, string $className, array $mapping ) : array
$joinTableAnnotation Doctrine\ORM\Mapping\JoinTable
$property ReflectionProperty
$className string
$mapping array
return array

evaluateLifeCycleAnnotations() protected method

Evaluate the lifecycle annotations and amend the metadata accordingly.
protected evaluateLifeCycleAnnotations ( ReflectionClass $class, Doctrine\ORM\Mapping\ClassMetadataInfo $metadata ) : void
$class ReflectionClass
$metadata Doctrine\ORM\Mapping\ClassMetadataInfo
return void

evaluateOverridesAnnotations() protected method

Evaluate the association overrides annotations and amend the metadata accordingly.
protected evaluateOverridesAnnotations ( array $classAnnotations, Doctrine\ORM\Mapping\ClassMetadataInfo $metadata ) : void
$classAnnotations array
$metadata Doctrine\ORM\Mapping\ClassMetadataInfo
return void

evaluatePropertyAnnotations() protected method

Evaluate the property annotations and amend the metadata accordingly.
protected evaluatePropertyAnnotations ( Doctrine\ORM\Mapping\ClassMetadataInfo $metadata ) : void
$metadata Doctrine\ORM\Mapping\ClassMetadataInfo
return void

getAllClassNames() public method

Returns the names of all mapped (non-transient) classes known to this driver.
public getAllClassNames ( ) : array
return array

getClassSchema() protected method

Fetch a class schema for the given class, if possible.
protected getClassSchema ( string $className ) : ClassSchema
$className string
return Neos\Flow\Reflection\ClassSchema

getMaxIdentifierLength() protected method

Derive maximum identifier length from doctrine DBAL
protected getMaxIdentifierLength ( ) : integer
return integer

getMethodCallbacks() protected method

Returns an array of callbacks for lifecycle annotations on the given method.
protected getMethodCallbacks ( ReflectionMethod $method ) : array
$method ReflectionMethod
return array

getRuntimeEvaluationsDefinition() public method

Returns runtime evaluations for a previously matched pointcut
public getRuntimeEvaluationsDefinition ( ) : array
return array Runtime evaluations

getUnproxiedClassName() protected method

Returns the classname after stripping a potentially present Compiler::ORIGINAL_CLASSNAME_SUFFIX.
protected getUnproxiedClassName ( string $className ) : string
$className string
return string

hasRuntimeEvaluationsDefinition() public method

Returns TRUE if this filter holds runtime evaluations for a previously matched pointcut
public hasRuntimeEvaluationsDefinition ( ) : boolean
return boolean TRUE if this filter has runtime evaluations

inferJoinTableNameFromClassAndPropertyName() protected method

Given a class and property name a table name is returned. That name should be reasonably unique.
protected inferJoinTableNameFromClassAndPropertyName ( string $className, string $propertyName ) : string
$className string Model class name the table corresponds to
$propertyName string Name of the property to be joined
return string Truncated database table name

inferTableNameFromClassName() public method

Given a class name a table name is returned. That name should be reasonably unique.
public inferTableNameFromClassName ( string $className, integer $lengthLimit = null ) : string
$className string
$lengthLimit integer
return string

injectReflectionService() public method

public injectReflectionService ( ReflectionService $reflectionService ) : void
$reflectionService Neos\Flow\Reflection\ReflectionService
return void

isAggregateRoot() protected method

Check for $className being an aggregate root.
protected isAggregateRoot ( string $className, string $propertySourceHint ) : boolean
$className string
$propertySourceHint string
return boolean

isTransient() public method

Returns whether the class with the specified name is transient. Only non-transient classes, that is entities and mapped superclasses, should have their metadata loaded.
public isTransient ( string $className ) : boolean
$className string
return boolean

isValueObject() protected method

Check for $className being a value object.
protected isValueObject ( string $className, string $propertySourceHint ) : boolean
$className string
$propertySourceHint string
return boolean

joinColumnToArray() protected method

Parse the given JoinColumn into an array
protected joinColumnToArray ( Doctrine\ORM\Mapping\JoinColumn $joinColumnAnnotation, string $propertyName = null ) : array
$joinColumnAnnotation Doctrine\ORM\Mapping\JoinColumn
$propertyName string
return array

loadMetadataForClass() public method

Loads the metadata for the specified class into the provided container.
public loadMetadataForClass ( string $className, Doctrine\Common\Persistence\Mapping\ClassMetadata $metadata ) : void
$className string
$metadata Doctrine\Common\Persistence\Mapping\ClassMetadata
return void

matches() public method

Checks if the specified class has a property annotated with Id
public matches ( string $className, string $methodName, string $methodDeclaringClassName, mixed $pointcutQueryIdentifier ) : boolean
$className string Name of the class to check against
$methodName string Name of the method to check against
$methodDeclaringClassName string Name of the class the method was originally declared in
$pointcutQueryIdentifier mixed Some identifier for this query - must at least differ from a previous identifier. Used for circular reference detection.
return boolean TRUE if the class has *no* Id properties

reduceTargetClassNames() public method

This method is used to optimize the matching process.
public reduceTargetClassNames ( ClassNameIndex $classNameIndex ) : ClassNameIndex
$classNameIndex Neos\Flow\Aop\Builder\ClassNameIndex
return Neos\Flow\Aop\Builder\ClassNameIndex

setEntityManager() public method

public setEntityManager ( Doctrine\Common\Persistence\ObjectManager $entityManager ) : void
$entityManager Doctrine\Common\Persistence\ObjectManager
return void

truncateIdentifier() protected method

Truncate an identifier if needed and append a hash to ensure uniqueness.
protected truncateIdentifier ( string $identifier, integer $lengthLimit = null, string $hashSource = null ) : string
$identifier string
$lengthLimit integer
$hashSource string
return string

Property Details

$classNames protected_oe property

protected array $classNames
return array

$entityManager protected_oe property

protected ObjectManager,Doctrine\Common\Persistence $entityManager
return Doctrine\Common\Persistence\ObjectManager

$reader protected_oe property

protected AnnotationReader,Doctrine\Common\Annotations $reader
return Doctrine\Common\Annotations\AnnotationReader

$reflectionService protected_oe property

protected ReflectionService,Neos\Flow\Reflection $reflectionService
return Neos\Flow\Reflection\ReflectionService

$tableNameLengthLimit protected_oe property

protected int $tableNameLengthLimit
return integer