abstract class FileDriver implements MappingDriver (View source)

Base driver for file-based metadata drivers.

A file driver operates in a mode where it loads the mapping files of individual classes on demand. This requires the user to adhere to the convention of 1 mapping file per class and the file names of the mapping files must correspond to the full class name, including namespace, with the namespace delimiters '\', replaced by dots '.'.

Properties

protected FileLocator $locator
protected array $classCache
protected string $globalBasename

Methods

__construct($locator, $fileExtension = null)

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

setGlobalBasename($file)

No description

getGlobalBasename()

No description

array
getElement($className)

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

boolean
isTransient(string $className)

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()

Initialize the class cache from all the global files.

Details

__construct($locator, $fileExtension = null)

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

Parameters

$locator
$fileExtension

setGlobalBasename($file)

Parameters

$file

getGlobalBasename()

array getElement($className)

Get 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

$className

Return Value

array $element The element of schema meta data

boolean isTransient(string $className)

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.

abstract 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()

Initialize 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