AbstractClassMetadataFactory
in package
implements
ClassMetadataFactory
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
Interfaces, Classes and Traits
- ClassMetadataFactory
- Contract for a Doctrine persistence layer ClassMetadata class to implement.
Table of Contents
- $cacheSalt : string
- Salt used by specific Object Manager implementation.
- $initialized : bool
- $cacheDriver : Cache|null
- $loadedMetadata : array<string|int, ClassMetadata>
- $reflectionService : ReflectionService|null
- getAllMetadata() : array<string|int, mixed>
- Forces the factory to load the metadata of all classes known to the underlying mapping driver.
- getCacheDriver() : Cache|null
- Gets the cache driver used by the factory to cache ClassMetadata instances.
- 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.
- setCacheDriver() : void
- Sets the cache driver used by the factory to cache ClassMetadata instances.
- setMetadataFor() : void
- Sets the metadata descriptor for a specific class.
- setReflectionService() : void
- Sets the reflectionService.
- doLoadMetadata() : void
- Actually loads the metadata from the underlying metadata.
- getDriver() : MappingDriver
- Returns the mapping driver implementation.
- getFqcnFromAlias() : string
- Gets the fully qualified class-name from the namespace alias.
- getParentClasses() : array<string|int, mixed>
- 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<string|int, mixed>
- Loads the metadata of the class in question and all it's ancestors whose metadata is still not loaded.
- newClassMetadataInstance() : ClassMetadata
- 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.
Properties
$cacheSalt
Salt used by specific Object Manager implementation.
protected
string
$cacheSalt
= '$CLASSMETADATA'
$initialized
protected
bool
$initialized
= false
$cacheDriver
private
Cache|null
$cacheDriver
$loadedMetadata
private
array<string|int, ClassMetadata>
$loadedMetadata
= []
$reflectionService
private
ReflectionService|null
$reflectionService
= null
Methods
getAllMetadata()
Forces the factory to load the metadata of all classes known to the underlying mapping driver.
public
getAllMetadata() : array<string|int, mixed>
Return values
array<string|int, mixed> —The ClassMetadata instances of all mapped classes.
getCacheDriver()
Gets the cache driver used by the factory to cache ClassMetadata instances.
public
getCacheDriver() : Cache|null
Return values
Cache|null —getLoadedMetadata()
Returns an array of all the loaded metadata currently in memory.
public
getLoadedMetadata() : array<string|int, ClassMetadata>
Return values
array<string|int, ClassMetadata> —getMetadataFor()
Gets the class metadata descriptor for a class.
public
getMetadataFor(string $className) : ClassMetadata
Parameters
- $className : string
-
The name of the class.
Tags
Return values
ClassMetadata —getReflectionService()
Gets the reflection service associated with this metadata factory.
public
getReflectionService() : ReflectionService
Return values
ReflectionService —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(mixed $class) : bool
Parameters
- $class : mixed
Return values
bool —setCacheDriver()
Sets the cache driver used by the factory to cache ClassMetadata instances.
public
setCacheDriver([Cache $cacheDriver = null ]) : void
Parameters
- $cacheDriver : Cache = null
Return values
void —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
Return values
void —setReflectionService()
Sets the reflectionService.
public
setReflectionService(ReflectionService $reflectionService) : void
Parameters
- $reflectionService : ReflectionService
Return values
void —doLoadMetadata()
Actually loads the metadata from the underlying metadata.
protected
abstract doLoadMetadata(ClassMetadata $class, ClassMetadata|null $parent, bool $rootEntityFound, array<string|int, mixed> $nonSuperclassParents) : void
Parameters
- $class : ClassMetadata
- $parent : ClassMetadata|null
- $rootEntityFound : bool
- $nonSuperclassParents : array<string|int, mixed>
-
All parent class names that are not marked as mapped superclasses.
Return values
void —getDriver()
Returns the mapping driver implementation.
protected
abstract getDriver() : MappingDriver
Return values
MappingDriver —getFqcnFromAlias()
Gets the fully qualified class-name from the namespace alias.
protected
abstract getFqcnFromAlias(string $namespaceAlias, string $simpleClassName) : string
Parameters
- $namespaceAlias : string
- $simpleClassName : string
Return values
string —getParentClasses()
Gets an array of parent classes for the given entity class.
protected
getParentClasses(string $name) : array<string|int, mixed>
Parameters
- $name : string
Return values
array<string|int, mixed> —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
Return values
void —initializeReflection()
Initializes Reflection after ClassMetadata was constructed.
protected
abstract initializeReflection(ClassMetadata $class, ReflectionService $reflService) : void
Parameters
- $class : ClassMetadata
- $reflService : ReflectionService
Return values
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
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<string|int, mixed>
Important: The class $name does not necesarily 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.
Return values
array<string|int, mixed> —newClassMetadataInstance()
Creates a new ClassMetadata instance for the given class name.
protected
abstract newClassMetadataInstance(string $className) : ClassMetadata
Parameters
- $className : string
Return values
ClassMetadata —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
Return values
ClassMetadata|null —wakeupReflection()
Wakes up reflection after ClassMetadata gets unserialized from cache.
protected
abstract wakeupReflection(ClassMetadata $class, ReflectionService $reflService) : void
Parameters
- $class : ClassMetadata
- $reflService : ReflectionService