class FlowAnnotationDriver implements MappingDriver, PointcutFilterInterface (View source)

This driver reads the mapping metadata from docblock annotations.

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.

Constants

MAPPING_REGULAR

MAPPING_MM_REGULAR

Properties

protected ReflectionService $reflectionService
protected Reader $reader
protected EntityManagerInterface $entityManager
protected array $classNames
protected int $tableNameLengthLimit

Methods

__construct()

Initializes a new AnnotationDriver that uses the given AnnotationReader for reading docblock annotations.

void
injectReflectionService(ReflectionService $reflectionService)

No description

void
setEntityManager(EntityManagerInterface $entityManager)

No description

getClassSchema(string $className)

Fetch a class schema for the given class, if possible.

bool
isAggregateRoot(string $className, string $propertySourceHint)

Check for $className being an aggregate root.

bool
isValueObject(string $className, string $propertySourceHint)

Check for $className being a value object.

void
loadMetadataForClass(string $className, ClassMetadata $metadata)

Loads the metadata for the specified class into the provided container.

string
inferTableNameFromClassName(string $className, int $lengthLimit = null)

Given a class name a table name is returned. That name should be reasonably unique.

static string
inferDiscriminatorTypeFromClassName(string $className)

Given a class name returns a value to be used as a discriminator type value.

string
truncateIdentifier(string $identifier, int $lengthLimit = null, string $hashSource = null)

Truncate an identifier if needed and append a hash to ensure uniqueness.

string
inferJoinTableNameFromClassAndPropertyName(string $className, string $propertyName)

Given a class and property name a table name is returned. That name should be reasonably unique.

string
buildJoinTableColumnName(string $className)

Build a name for a column in a jointable.

array
buildJoinColumnsIfNeeded(array $joinColumns, array $mapping, ReflectionProperty $property, int $direction = self::MAPPING_REGULAR)

Check if the referenced column name is set (and valid) and if not make sure it is initialized properly.

void
evaluatePropertyAnnotations(ClassMetadataInfo $metadata)

Evaluate the property annotations and amend the metadata accordingly.

array
evaluateJoinTableAnnotation(JoinTable $joinTableAnnotation, ReflectionProperty $property, string $className, array $mapping)

Evaluate JoinTable annotations and fill missing bits as needed.

array
evaluateJoinColumnAnnotations(ReflectionProperty $property)

Check for and build JoinColummn/JoinColumns annotations.

void
evaluateOverridesAnnotations(array $classAnnotations, ClassMetadataInfo $metadata)

Evaluate the association overrides annotations and amend the metadata accordingly.

void
evaluateEntityListenersAnnotation(ReflectionClass $class, ClassMetadata $metadata, array $classAnnotations)

Evaluate the EntityListeners annotation and amend the metadata accordingly.

void
evaluateLifeCycleAnnotations(ReflectionClass $class, ClassMetadataInfo $metadata)

Evaluate the lifecycle annotations and amend the metadata accordingly.

array
getMethodCallbacks(ReflectionMethod $method)

Returns an array of callbacks for lifecycle annotations on the given method.

int
getMaxIdentifierLength()

Derive maximum identifier length from doctrine DBAL

bool
isTransient(string $className)

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.

array
getAllClassNames()

Returns the names of all mapped (non-transient) classes known to this driver.

array
joinColumnToArray(JoinColumn $joinColumnAnnotation, string $propertyName = null)

Parse the given JoinColumn into an array

array
addColumnToMappingArray(Column $columnAnnotation, array $mapping = [], string $fieldName = null)

Parse the given Column into an array

string
getUnproxiedClassName(string $className)

Returns the classname after stripping a potentially present Compiler::ORIGINAL_CLASSNAME_SUFFIX.

bool
matches(string $className, string $methodName, string $methodDeclaringClassName, mixed $pointcutQueryIdentifier)

Checks if the specified class has a property annotated with Id

bool
hasRuntimeEvaluationsDefinition()

Returns true if this filter holds runtime evaluations for a previously matched pointcut

array
getRuntimeEvaluationsDefinition()

Returns runtime evaluations for a previously matched pointcut

reduceTargetClassNames(ClassNameIndex $classNameIndex)

This method is used to optimize the matching process.

Details

__construct()

Initializes a new AnnotationDriver that uses the given AnnotationReader for reading docblock annotations.

void injectReflectionService(ReflectionService $reflectionService)

No description

Parameters

ReflectionService $reflectionService

Return Value

void

void setEntityManager(EntityManagerInterface $entityManager)

No description

Parameters

EntityManagerInterface $entityManager

Return Value

void

protected ClassSchema getClassSchema(string $className)

Fetch a class schema for the given class, if possible.

Parameters

string $className

Return Value

ClassSchema

Exceptions

ClassSchemaNotFoundException

protected bool isAggregateRoot(string $className, string $propertySourceHint)

Check for $className being an aggregate root.

Parameters

string $className
string $propertySourceHint

Return Value

bool

Exceptions

ClassSchemaNotFoundException

protected bool isValueObject(string $className, string $propertySourceHint)

Check for $className being a value object.

Parameters

string $className
string $propertySourceHint

Return Value

bool

Exceptions

ClassSchemaNotFoundException

void loadMetadataForClass(string $className, ClassMetadata $metadata)

Loads the metadata for the specified class into the provided container.

Parameters

string $className
ClassMetadata $metadata

Return Value

void

Exceptions

MappingException
UnexpectedValueException

string inferTableNameFromClassName(string $className, int $lengthLimit = null)

Given a class name a table name is returned. That name should be reasonably unique.

Parameters

string $className
int $lengthLimit

Return Value

string

static string inferDiscriminatorTypeFromClassName(string $className)

Given a class name returns a value to be used as a discriminator type value.

Parameters

string $className

Return Value

string

protected string truncateIdentifier(string $identifier, int $lengthLimit = null, string $hashSource = null)

Truncate an identifier if needed and append a hash to ensure uniqueness.

Parameters

string $identifier
int $lengthLimit
string $hashSource

Return Value

string

protected string inferJoinTableNameFromClassAndPropertyName(string $className, string $propertyName)

Given a class and property name a table name is returned. That name should be reasonably unique.

Parameters

string $className

Model class name the table corresponds to

string $propertyName

Name of the property to be joined

Return Value

string

Truncated database table name

protected string buildJoinTableColumnName(string $className)

Build a name for a column in a jointable.

Parameters

string $className

Return Value

string

protected array buildJoinColumnsIfNeeded(array $joinColumns, array $mapping, ReflectionProperty $property, int $direction = self::MAPPING_REGULAR)

Check if the referenced column name is set (and valid) and if not make sure it is initialized properly.

Parameters

array $joinColumns
array $mapping
ReflectionProperty $property
int $direction

regular or inverse mapping (use is to be coded)

Return Value

array

protected void evaluatePropertyAnnotations(ClassMetadataInfo $metadata)

Evaluate the property annotations and amend the metadata accordingly.

Parameters

ClassMetadataInfo $metadata

Return Value

void

Exceptions

MappingException

protected array evaluateJoinTableAnnotation(JoinTable $joinTableAnnotation, ReflectionProperty $property, string $className, array $mapping)

Evaluate JoinTable annotations and fill missing bits as needed.

Parameters

JoinTable $joinTableAnnotation
ReflectionProperty $property
string $className
array $mapping

Return Value

array

protected array evaluateJoinColumnAnnotations(ReflectionProperty $property)

Check for and build JoinColummn/JoinColumns annotations.

If no annotations are found, a default is returned.

Parameters

ReflectionProperty $property

Return Value

array

protected void evaluateOverridesAnnotations(array $classAnnotations, ClassMetadataInfo $metadata)

Evaluate the association overrides annotations and amend the metadata accordingly.

Parameters

array $classAnnotations
ClassMetadataInfo $metadata

Return Value

void

protected void evaluateEntityListenersAnnotation(ReflectionClass $class, ClassMetadata $metadata, array $classAnnotations)

Evaluate the EntityListeners annotation and amend the metadata accordingly.

Parameters

ReflectionClass $class
ClassMetadata $metadata
array $classAnnotations

Return Value

void

Exceptions

MappingException

protected void evaluateLifeCycleAnnotations(ReflectionClass $class, ClassMetadataInfo $metadata)

Evaluate the lifecycle annotations and amend the metadata accordingly.

Parameters

ReflectionClass $class
ClassMetadataInfo $metadata

Return Value

void

protected array getMethodCallbacks(ReflectionMethod $method)

Returns an array of callbacks for lifecycle annotations on the given method.

Parameters

ReflectionMethod $method

Return Value

array

protected int getMaxIdentifierLength()

Derive maximum identifier length from doctrine DBAL

Return Value

int

bool isTransient(string $className)

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.

Parameters

string $className

Return Value

bool

array getAllClassNames()

Returns the names of all mapped (non-transient) classes known to this driver.

Return Value

array

protected array joinColumnToArray(JoinColumn $joinColumnAnnotation, string $propertyName = null)

Parse the given JoinColumn into an array

Parameters

JoinColumn $joinColumnAnnotation
string $propertyName

Return Value

array

protected array addColumnToMappingArray(Column $columnAnnotation, array $mapping = [], string $fieldName = null)

Parse the given Column into an array

Parameters

Column $columnAnnotation
array $mapping
string $fieldName

Return Value

array

protected string getUnproxiedClassName(string $className)

Returns the classname after stripping a potentially present Compiler::ORIGINAL_CLASSNAME_SUFFIX.

Parameters

string $className

Return Value

string

bool matches(string $className, string $methodName, string $methodDeclaringClassName, mixed $pointcutQueryIdentifier)

Checks if the specified class has a property annotated with Id

Parameters

string $className

Name of the class to check against

string $methodName

Name of the method to check against

string $methodDeclaringClassName

Name of the class the method was originally declared in

mixed $pointcutQueryIdentifier

Some identifier for this query - must at least differ from a previous identifier. Used for circular reference detection.

Return Value

bool

true if the class / method match, otherwise false

bool hasRuntimeEvaluationsDefinition()

Returns true if this filter holds runtime evaluations for a previously matched pointcut

Return Value

bool

true if this filter has runtime evaluations

array getRuntimeEvaluationsDefinition()

Returns runtime evaluations for a previously matched pointcut

Return Value

array

Runtime evaluations

ClassNameIndex reduceTargetClassNames(ClassNameIndex $classNameIndex)

This method is used to optimize the matching process.

Parameters

ClassNameIndex $classNameIndex

An index of class names

Return Value

ClassNameIndex

The filtered result, with pointcuts possibly covered by this filter