Documentation

FileDriver
in package
implements MappingDriver

AbstractYes

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 '.'.

Table of Contents

Interfaces

MappingDriver
Contract for metadata drivers.

Properties

$classCache  : array<string|int, ClassMetadata>|null
$globalBasename  : string
$locator  : FileLocator

Methods

__construct()  : mixed
Initializes a new FileDriver that looks in the given path(s) for mapping documents and operates in the specified operating mode.
getAllClassNames()  : array<int, string>
Gets the names of all mapped classes known to this driver.
getElement()  : ClassMetadata
Gets the element of schema meta data for the class from the mapping file.
getGlobalBasename()  : string|null
Retrieves the global basename.
getLocator()  : FileLocator
Retrieves the locator used to discover mapping files by className.
isTransient()  : bool
Returns whether the class with the specified name should have its metadata loaded.
setGlobalBasename()  : void
Sets the global basename.
setLocator()  : void
Sets the locator used to discover mapping files by className.
initialize()  : void
Initializes the class cache from all the global files.
loadMappingFile()  : array<string|int, ClassMetadata>
Loads a mapping file with the given name and returns a map from class/entity names to their corresponding file driver elements.

Properties

$classCache

protected array<string|int, ClassMetadata>|null $classCache
Tags
psalm-var

array<class-string, ClassMetadata>|null

$globalBasename

protected string $globalBasename = ''

Methods

__construct()

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

public __construct(string|array<int, string>|FileLocator $locator[, string|null $fileExtension = null ]) : mixed
Parameters
$locator : string|array<int, string>|FileLocator

A FileLocator or one/multiple paths where mapping documents can be found.

$fileExtension : string|null = null

getAllClassNames()

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

public getAllClassNames() : array<int, string>
Return values
array<int, string>

The names of all mapped classes known to this driver.

getElement()

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

public getElement(string $className) : ClassMetadata

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

Parameters
$className : string
Tags
psalm-param

class-string $className

psalm-return

ClassMetadata

throws
MappingException
Return values
ClassMetadata

The element of schema meta data.

getGlobalBasename()

Retrieves the global basename.

public getGlobalBasename() : string|null
Return values
string|null

isTransient()

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

public isTransient(string $className) : bool
Parameters
$className : string
Return values
bool

setGlobalBasename()

Sets the global basename.

public setGlobalBasename(string $file) : void
Parameters
$file : string

initialize()

Initializes the class cache from all the global files.

protected initialize() : void

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.

loadMappingFile()

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

protected abstract loadMappingFile(string $file) : array<string|int, ClassMetadata>
Parameters
$file : string

The mapping file to load.

Tags
psalm-return

array<class-string, ClassMetadata>

Return values
array<string|int, ClassMetadata>

        
On this page

Search results