class AnnotationDriver implements MappingDriver (View source)

The AnnotationDriver reads the mapping metadata from docblock annotations.

Properties

protected int[] $entityAnnotationClasses
protected AnnotationReader $reader The AnnotationReader.
protected string[] $paths The paths where to look for mapping files.
protected string[] $excludePaths The paths excluded from path where to look for mapping files.
protected string $fileExtension The file extension of mapping documents.
protected string[]|null $classNames Cache for AnnotationDriver#getAllClassNames().

Methods

__construct(AnnotationReader $reader, string|string[]|null $paths = null)

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

addPaths(array $paths)

Appends lookup paths to metadata driver.

string[]
getPaths()

Retrieves the defined metadata lookup paths.

addExcludePaths(array $paths)

Append exclude lookup paths to metadata driver.

string[]
getExcludePaths()

Retrieve the defined metadata lookup exclude paths.

AnnotationReader
getReader()

Retrieve the current annotation reader

string
getFileExtension()

Gets the file extension used to look for mapping files under.

setFileExtension(string $fileExtension)

Sets the file extension used to look for mapping files under.

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.

string[]
getAllClassNames()

Gets the names of all mapped classes known to this driver.

void
loadMetadataForClass(string $className, ClassMetadata $metadata, ClassMetadataBuildingContext $metadataBuildingContext)

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

create($paths = [], AnnotationReader|null $reader = null)

Factory method for the Annotation Driver.

Details

__construct(AnnotationReader $reader, string|string[]|null $paths = null)

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

Parameters

AnnotationReader $reader The AnnotationReader to use, duck-typed.
string|string[]|null $paths One or multiple paths where mapping classes can be found.

addPaths(array $paths)

Appends lookup paths to metadata driver.

Parameters

array $paths

string[] getPaths()

Retrieves the defined metadata lookup paths.

Return Value

string[]

addExcludePaths(array $paths)

Append exclude lookup paths to metadata driver.

Parameters

array $paths

string[] getExcludePaths()

Retrieve the defined metadata lookup exclude paths.

Return Value

string[]

AnnotationReader getReader()

Retrieve the current annotation reader

Return Value

AnnotationReader

string getFileExtension()

Gets the file extension used to look for mapping files under.

Return Value

string

setFileExtension(string $fileExtension)

Sets the file extension used to look for mapping files under.

Parameters

string $fileExtension The file extension to set.

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.

A class is non-transient if it is annotated with an annotation from the {see AnnotationDriver::entityAnnotationClasses}.

Parameters

string $className

Return Value

bool

string[] getAllClassNames()

Gets the names of all mapped classes known to this driver.

Return Value

string[] The names of all mapped classes known to this driver.

void loadMetadataForClass(string $className, ClassMetadata $metadata, ClassMetadataBuildingContext $metadataBuildingContext)

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

Parameters

string $className
ClassMetadata $metadata
ClassMetadataBuildingContext $metadataBuildingContext

Return Value

void

static AnnotationDriver create($paths = [], AnnotationReader|null $reader = null)

Factory method for the Annotation Driver.

Parameters

$paths
AnnotationReader|null $reader

Return Value

AnnotationDriver