class PHPDriver extends FileDriver (View source)

The PHPDriver includes php files which just populate ClassMetadataInfo instances with plain PHP code.

Properties

protected FileLocator $locator from FileDriver
protected array|null $classCache from FileDriver
protected string|null $globalBasename from FileDriver
protected ClassMetadata $metadata

Methods

__construct(string|array|FileLocator $locator)

Initializes a new FileDriver that looks in the given path(s) for mapping documents and operates in the specified operating mode.

void
setGlobalBasename(string $file)

Sets the global basename.

string|null
getGlobalBasename()

Retrieves the global basename.

array
getElement(string $className)

Gets the element of schema meta data for the class from the mapping file.

boolean
isTransient(string $className)

Returns whether the class with the specified name should have its metadata loaded.

array
getAllClassNames()

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

array
loadMappingFile(string $file)

Loads a mapping file with the given name and returns a map from class/entity names to their corresponding file driver elements.

void
initialize()

Initializes the class cache from all the global files.

getLocator()

Retrieves the locator used to discover mapping files by className.

setLocator(FileLocator $locator)

Sets the locator used to discover mapping files by className.

void
loadMetadataForClass(string $className, ClassMetadata $metadata)

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

Details

__construct(string|array|FileLocator $locator)

Initializes a new FileDriver that looks in the given path(s) for mapping documents and operates in the specified operating mode.

Parameters

string|array|FileLocator $locator A FileLocator or one/multiple paths where mapping documents can be found.

void setGlobalBasename(string $file)

Sets the global basename.

Parameters

string $file

Return Value

void

string|null getGlobalBasename()

Retrieves the global basename.

Return Value

string|null

array getElement(string $className)

Gets the element of schema meta data for the class from the mapping file.

This will lazily load the mapping file if it is not loaded yet.

Parameters

string $className

Return Value

array The element of schema meta data.

Exceptions

MappingException

boolean isTransient(string $className)

Returns whether the class with the specified name should have its metadata loaded.

This is only the case if it is either mapped as an Entity or a MappedSuperclass.

Parameters

string $className

Return Value

boolean

array getAllClassNames()

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

Return Value

array The names of all mapped classes known to this driver.

protected array loadMappingFile(string $file)

Loads a mapping file with the given name and returns a map from class/entity names to their corresponding file driver elements.

Parameters

string $file The mapping file to load.

Return Value

array

protected void initialize()

Initializes the class cache from all the global files.

Using this feature adds a substantial performance hit to file drivers as more metadata has to be loaded into memory than might actually be necessary. This may not be relevant to scenarios where caching of metadata is in place, however hits very hard in scenarios where no caching is used.

Return Value

void

FileLocator getLocator()

Retrieves the locator used to discover mapping files by className.

Return Value

FileLocator

setLocator(FileLocator $locator)

Sets the locator used to discover mapping files by className.

Parameters

FileLocator $locator

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