Documentation

AbstractClassMetadataFactory
in package
implements ClassMetadataFactory

AbstractYes

The ClassMetadataFactory is used to create ClassMetadata objects that contain all the metadata mapping informations of a class which describes how a class should be mapped to a relational database.

This class was abstracted from the ORM ClassMetadataFactory.

Tags
template

CMTemplate of ClassMetadata

template-implements

ClassMetadataFactory<CMTemplate>

Table of Contents

Interfaces

ClassMetadataFactory
Contract for a Doctrine persistence layer ClassMetadata class to implement.

Properties

$cacheSalt  : string
Salt used by specific Object Manager implementation.
$initialized  : bool
$cache  : CacheItemPoolInterface|null
$loadedMetadata  : array<string, ClassMetadata>
$proxyClassNameResolver  : ProxyClassNameResolver|null
$reflectionService  : ReflectionService|null

Methods

getAllMetadata()  : array<string|int, ClassMetadata>
Forces the factory to load the metadata of all classes known to the underlying mapping driver.
getLoadedMetadata()  : array<string|int, ClassMetadata>
Returns an array of all the loaded metadata currently in memory.
getMetadataFor()  : ClassMetadata
Gets the class metadata descriptor for a class.
getReflectionService()  : ReflectionService
Gets the reflection service associated with this metadata factory.
hasMetadataFor()  : bool
Checks whether the factory has the metadata for a class loaded already.
isTransient()  : bool
Returns whether the class with the specified name should have its metadata loaded.
setCache()  : void
setMetadataFor()  : void
Sets the metadata descriptor for a specific class.
setProxyClassNameResolver()  : void
setReflectionService()  : void
Sets the reflectionService.
doLoadMetadata()  : void
Actually loads the metadata from the underlying metadata.
getCache()  : CacheItemPoolInterface|null
getCacheKey()  : string
getDriver()  : MappingDriver
Returns the mapping driver implementation.
getParentClasses()  : array<string|int, string>
Gets an array of parent classes for the given entity class.
initialize()  : void
Lazy initialization of this stuff, especially the metadata driver, since these are not needed at all when a metadata cache is active.
initializeReflection()  : void
Initializes Reflection after ClassMetadata was constructed.
isEntity()  : bool
Checks whether the class metadata is an entity.
loadMetadata()  : array<int, string>
Loads the metadata of the class in question and all it's ancestors whose metadata is still not loaded.
newClassMetadataInstance()  : ClassMetadata<string|int, T>
Creates a new ClassMetadata instance for the given class name.
onNotFoundMetadata()  : ClassMetadata|null
Provides a fallback hook for loading metadata when loading failed due to reflection/mapping exceptions
wakeupReflection()  : void
Wakes up reflection after ClassMetadata gets unserialized from cache.
createDefaultProxyClassNameResolver()  : void
getRealClass()  : string
Gets the real class name of a class name that could be a proxy.
normalizeClassName()  : string
Removes the prepended backslash of a class string to conform with how php outputs class names

Properties

Methods

getAllMetadata()

Forces the factory to load the metadata of all classes known to the underlying mapping driver.

public getAllMetadata() : array<string|int, ClassMetadata>
Return values
array<string|int, ClassMetadata>

The ClassMetadata instances of all mapped classes.

hasMetadataFor()

Checks whether the factory has the metadata for a class loaded already.

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

TRUE if the metadata of the class in question is already loaded, FALSE otherwise.

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

setMetadataFor()

Sets the metadata descriptor for a specific class.

public setMetadataFor(string $className, ClassMetadata $class) : void

NOTE: This is only useful in very special cases, like when generating proxy classes.

Parameters
$className : string
$class : ClassMetadata
Tags
psalm-param

class-string $className

psalm-param

CMTemplate $class

doLoadMetadata()

Actually loads the metadata from the underlying metadata.

protected abstract doLoadMetadata(ClassMetadata $class, ClassMetadata|null $parent, bool $rootEntityFound, array<int, class-string> $nonSuperclassParents) : void
Parameters
$class : ClassMetadata
$parent : ClassMetadata|null
$rootEntityFound : bool

True when there is another entity (non-mapped superclass) class above the current class in the PHP class hierarchy.

$nonSuperclassParents : array<int, class-string>

All parent class names that are not marked as mapped superclasses, with the direct parent class being the first and the root entity class the last element.

Tags
psalm-param

CMTemplate $class

psalm-param

CMTemplate|null $parent

getCacheKey()

protected getCacheKey(string $realClassName) : string
Parameters
$realClassName : string
Return values
string

getParentClasses()

Gets an array of parent classes for the given entity class.

protected getParentClasses(string $name) : array<string|int, string>
Parameters
$name : string
Tags
psalm-param

class-string $name

psalm-return

list

Return values
array<string|int, string>

initialize()

Lazy initialization of this stuff, especially the metadata driver, since these are not needed at all when a metadata cache is active.

protected abstract initialize() : void

isEntity()

Checks whether the class metadata is an entity.

protected abstract isEntity(ClassMetadata $class) : bool

This method should return false for mapped superclasses or embedded classes.

Parameters
$class : ClassMetadata
Tags
psalm-param

CMTemplate $class

Return values
bool

loadMetadata()

Loads the metadata of the class in question and all it's ancestors whose metadata is still not loaded.

protected loadMetadata(string $name) : array<int, string>

Important: The class $name does not necessarily exist at this point here. Scenarios in a code-generation setup might have access to XML/YAML Mapping files without the actual PHP code existing here. That is why the ReflectionService interface should be used for reflection.

Parameters
$name : string

The name of the class for which the metadata should get loaded.

Tags
psalm-param

class-string $name

psalm-return

list

Return values
array<int, string>

newClassMetadataInstance()

Creates a new ClassMetadata instance for the given class name.

protected abstract newClassMetadataInstance(string $className) : ClassMetadata<string|int, T>
Parameters
$className : string
Tags
psalm-param

class-string<T> $className

psalm-return

CMTemplate

template

T of object

Return values
ClassMetadata<string|int, T>

onNotFoundMetadata()

Provides a fallback hook for loading metadata when loading failed due to reflection/mapping exceptions

protected onNotFoundMetadata(string $className) : ClassMetadata|null

Override this method to implement a fallback strategy for failed metadata loading

Parameters
$className : string
Tags
psalm-return

CMTemplate|null

Return values
ClassMetadata|null

getRealClass()

Gets the real class name of a class name that could be a proxy.

private getRealClass(string $class) : string
Parameters
$class : string
Tags
psalm-param

class-string<Proxy<T>>|class-string<T> $class

psalm-return

class-string<T>

template

T of object

Return values
string

normalizeClassName()

Removes the prepended backslash of a class string to conform with how php outputs class names

private normalizeClassName(string $className) : string
Parameters
$className : string
Tags
psalm-param

class-string $className

psalm-return

class-string

Return values
string

        
On this page

Search results