Documentation

XmlDriver extends FileDriver
in package

XmlDriver is a metadata driver that enables mapping through XML files.

Tags
link
www.doctrine-project.org

Table of Contents

Constants

DEFAULT_FILE_EXTENSION  = '.dcm.xml'

Properties

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

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.
loadMetadataForClass()  : mixed
{@inheritDoc}
setGlobalBasename()  : void
Sets the global basename.
setLocator()  : void
Sets the locator used to discover mapping files by className.
evaluateBoolean()  : bool
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.
cacheToArray()  : array<string|int, mixed>
Parse / Normalize the cache configuration
columnToArray()  : array<string|int, mixed>
Parses the given field as array.
getCascadeMappings()  : array<string|int, string>
Gathers a list of cascade options found in the given cascade element.
joinColumnToArray()  : array<string|int, mixed>
Constructs a joinColumn mapping array based on the information found in the given SimpleXMLElement.
parseOptions()  : array<string|int, mixed>
Parses (nested) option elements.
validateMapping()  : void

Constants

DEFAULT_FILE_EXTENSION

public mixed DEFAULT_FILE_EXTENSION = '.dcm.xml'

Properties

$classCache

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

array<class-string, ClassMetadata>|null

$globalBasename

protected string $globalBasename = ''

$isXsdValidationEnabled

private bool $isXsdValidationEnabled

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(mixed $locator[, mixed $fileExtension = self::DEFAULT_FILE_EXTENSION ][, bool $isXsdValidationEnabled = false ]) : mixed
Parameters
$locator : mixed

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

$fileExtension : mixed = self::DEFAULT_FILE_EXTENSION
$isXsdValidationEnabled : bool = false

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

loadMetadataForClass()

{@inheritDoc}

public loadMetadataForClass(mixed $className, ClassMetadata $metadata) : mixed
Parameters
$className : mixed
$metadata : ClassMetadata
Tags
psalm-param

class-string<T> $className

psalm-param

ClassMetadata<T> $metadata

template

T of object

setGlobalBasename()

Sets the global basename.

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

evaluateBoolean()

protected evaluateBoolean(mixed $element) : bool
Parameters
$element : mixed
Return values
bool

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 loadMappingFile(mixed $file) : array<string|int, ClassMetadata>
Parameters
$file : mixed

The mapping file to load.

Return values
array<string|int, ClassMetadata>

cacheToArray()

Parse / Normalize the cache configuration

private cacheToArray(SimpleXMLElement $cacheMapping) : array<string|int, mixed>
Parameters
$cacheMapping : SimpleXMLElement
Tags
psalm-return

array{usage: int|null, region?: string}

Return values
array<string|int, mixed>

columnToArray()

Parses the given field as array.

private columnToArray(SimpleXMLElement $fieldMapping) : array<string|int, mixed>
Parameters
$fieldMapping : SimpleXMLElement
Tags
psalm-return

array{ fieldName: string, type?: string, columnName?: string, length?: int, precision?: int, scale?: int, unique?: bool, nullable?: bool, notInsertable?: bool, notUpdatable?: bool, enumType?: string, version?: bool, columnDefinition?: string, options?: array }

Return values
array<string|int, mixed>

getCascadeMappings()

Gathers a list of cascade options found in the given cascade element.

private getCascadeMappings(SimpleXMLElement $cascadeElement) : array<string|int, string>
Parameters
$cascadeElement : SimpleXMLElement

The cascade element.

Tags
psalm-return

list

Return values
array<string|int, string>

The list of cascade options.

joinColumnToArray()

Constructs a joinColumn mapping array based on the information found in the given SimpleXMLElement.

private joinColumnToArray(SimpleXMLElement $joinColumnElement) : array<string|int, mixed>
Parameters
$joinColumnElement : SimpleXMLElement

The XML element.

Tags
psalm-return

array{ name: string, referencedColumnName: string, unique?: bool, nullable?: bool, onDelete?: string, columnDefinition?: string, options?: mixed[] }

Return values
array<string|int, mixed>

The mapping array.

parseOptions()

Parses (nested) option elements.

private parseOptions(SimpleXMLElement $options) : array<string|int, mixed>
Parameters
$options : SimpleXMLElement

The XML element.

Tags
psalm-return

array<int|string, array<int|string, mixed|string>|bool|string>

Return values
array<string|int, mixed>

The options array.

validateMapping()

private validateMapping(string $file) : void
Parameters
$file : string

        
On this page

Search results