ClassMetadataFactory
extends AbstractClassMetadataFactory
in package
The ClassMetadataFactory is used to create ClassMetadata objects that contain all the metadata mapping information of a class which describes how a class should be mapped to a relational database.
Table of Contents
- $cacheSalt : string
- Salt used by specific Object Manager implementation.
- $initialized : bool
- $cache : CacheItemPoolInterface|null
- $cacheDriver : Cache|null
- $driver : MappingDriver
- $em : EntityManagerInterface|null
- $embeddablesActiveNesting : array<string|int, mixed>
- $evm : EventManager
- $loadedMetadata : array<string|int, ClassMetadata>
- $proxyClassNameResolver : ProxyClassNameResolver|null
- $reflectionService : ReflectionService|null
- $targetPlatform : AbstractPlatform|null
- getAllMetadata() : array<string|int, ClassMetadata>
- Forces the factory to load the metadata of all classes known to the underlying mapping driver.
- getAllMetadata() : array<string|int, ClassMetadata>
- 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.
- 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.
- 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
- setCacheDriver() : void
- Sets the cache driver used by the factory to cache ClassMetadata instances.
- setEntityManager() : 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.
- getFqcnFromAlias() : string
- Gets the fully qualified class-name from the namespace alias.
- 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<string|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
- validateRuntimeMetadata() : void
- Validate runtime metadata is correctly defined.
- wakeupReflection() : void
- Wakes up reflection after ClassMetadata gets unserialized from cache.
- addDefaultDiscriminatorMap() : void
- Adds a default discriminator map if no one is given
- addInheritedEmbeddedClasses() : void
- addInheritedFields() : void
- Adds inherited fields to the subclass mapping.
- addInheritedIndexes() : void
- Copy the table indices from the parent class superclass to the child class
- addInheritedNamedNativeQueries() : void
- Adds inherited named native queries to the subclass mapping.
- addInheritedNamedQueries() : void
- Adds inherited named queries to the subclass mapping.
- addInheritedRelations() : void
- Adds inherited association mappings to the subclass mapping.
- addInheritedSqlResultSetMappings() : void
- Adds inherited sql result set mappings to the subclass mapping.
- addNestedEmbeddedClasses() : void
- Adds nested embedded classes metadata to a parent class.
- completeIdGeneratorMapping() : void
- Completes the ID generator mapping. If "auto" is specified we choose the generator most appropriate for the targeted database platform.
- createDefaultProxyClassNameResolver() : void
- determineIdGeneratorStrategy() : int
- getRealClass() : string
- Gets the real class name of a class name that could be a proxy.
- getShortName() : string
- Gets the lower-case short name of a class.
- getTargetPlatform() : AbstractPlatform
- inheritIdGeneratorMapping() : void
- Inherits the ID generator mapping from a parent class.
- truncateSequenceName() : string
Properties
$cacheSalt
Salt used by specific Object Manager implementation.
protected
string
$cacheSalt
= '__CLASSMETADATA__'
$initialized
protected
bool
$initialized
= false
$cache
private
CacheItemPoolInterface|null
$cache
$cacheDriver
private
Cache|null
$cacheDriver
$driver
private
MappingDriver
$driver
$em
private
EntityManagerInterface|null
$em
$embeddablesActiveNesting
private
array<string|int, mixed>
$embeddablesActiveNesting
= []
$evm
private
EventManager
$evm
$loadedMetadata
private
array<string|int, ClassMetadata>
$loadedMetadata
= []
Tags
$proxyClassNameResolver
private
ProxyClassNameResolver|null
$proxyClassNameResolver
= null
$reflectionService
private
ReflectionService|null
$reflectionService
= null
$targetPlatform
private
AbstractPlatform|null
$targetPlatform
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.
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.
getCacheDriver()
Gets the cache driver used by the factory to cache ClassMetadata instances.
public
getCacheDriver() : Cache|null
Tags
Return values
Cache|null —getLoadedMetadata()
Returns an array of all the loaded metadata currently in memory.
public
getLoadedMetadata() : array<string|int, ClassMetadata>
Tags
Return values
array<string|int, ClassMetadata> —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(mixed $className) : ClassMetadata
Parameters
- $className : mixed
-
The name of the class.
Tags
Return values
ClassMetadata —getMetadataFor()
Gets the class metadata descriptor for a class.
public
getMetadataFor(mixed $className) : ClassMetadata
Parameters
- $className : mixed
-
The name of the class.
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(mixed $className) : bool
Parameters
- $className : mixed
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
Tags
Return values
bool —setCache()
public
setCache(CacheItemPoolInterface $cache) : void
Parameters
- $cache : CacheItemPoolInterface
Return values
void —setCacheDriver()
Sets the cache driver used by the factory to cache ClassMetadata instances.
public
setCacheDriver([Cache|null $cacheDriver = null ]) : void
Parameters
- $cacheDriver : Cache|null = null
Tags
Return values
void —setEntityManager()
public
setEntityManager(EntityManagerInterface $em) : void
Parameters
- $em : EntityManagerInterface
Return values
void —setMetadataFor()
Sets the metadata descriptor for a specific class.
public
setMetadataFor(mixed $className, mixed $class) : void
NOTE: This is only useful in very special cases, like when generating proxy classes.
Parameters
- $className : mixed
- $class : mixed
Return values
void —setProxyClassNameResolver()
public
setProxyClassNameResolver(ProxyClassNameResolver $resolver) : void
Parameters
- $resolver : ProxyClassNameResolver
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
doLoadMetadata(mixed $class, mixed $parent, mixed $rootEntityFound, array<string|int, mixed> $nonSuperclassParents) : void
Parameters
- $class : mixed
- $parent : mixed
- $rootEntityFound : mixed
- $nonSuperclassParents : array<string|int, mixed>
-
All parent class names that are not marked as mapped superclasses.
Return values
void —getCache()
protected
final getCache() : CacheItemPoolInterface|null
Return values
CacheItemPoolInterface|null —getCacheKey()
protected
getCacheKey(string $realClassName) : string
Parameters
- $realClassName : string
Return values
string —getDriver()
Returns the mapping driver implementation.
protected
getDriver() : MappingDriver
Return values
MappingDriver —getFqcnFromAlias()
Gets the fully qualified class-name from the namespace alias.
protected
getFqcnFromAlias(mixed $namespaceAlias, mixed $simpleClassName) : string
Parameters
- $namespaceAlias : mixed
- $simpleClassName : mixed
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
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
initialize() : void
Return values
void —initializeReflection()
Initializes Reflection after ClassMetadata was constructed.
protected
initializeReflection(ClassMetadata $class, ReflectionService $reflService) : void
Parameters
- $class : ClassMetadata
- $reflService : ReflectionService
Return values
void —isEntity()
Checks whether the class metadata is an entity.
protected
isEntity(ClassMetadata $class) : bool
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, 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
Return values
array<string|int, string> —newClassMetadataInstance()
Creates a new ClassMetadata instance for the given class name.
protected
newClassMetadataInstance(mixed $className) : ClassMetadata<string|int, T>
Parameters
- $className : mixed
Return values
ClassMetadata<string|int, T> —onNotFoundMetadata()
Provides a fallback hook for loading metadata when loading failed due to reflection/mapping exceptions
protected
onNotFoundMetadata(mixed $className) : ClassMetadata|null
Parameters
- $className : mixed
Return values
ClassMetadata|null —validateRuntimeMetadata()
Validate runtime metadata is correctly defined.
protected
validateRuntimeMetadata(ClassMetadata $class, ClassMetadata|null $parent) : void
Parameters
- $class : ClassMetadata
- $parent : ClassMetadata|null
Tags
Return values
void —wakeupReflection()
Wakes up reflection after ClassMetadata gets unserialized from cache.
protected
wakeupReflection(ClassMetadata $class, ReflectionService $reflService) : void
Parameters
- $class : ClassMetadata
- $reflService : ReflectionService
Return values
void —addDefaultDiscriminatorMap()
Adds a default discriminator map if no one is given
private
addDefaultDiscriminatorMap(ClassMetadata $class) : void
If an entity is of any inheritance type and does not contain a discriminator map, then the map is generated automatically. This process is expensive computation wise.
The automatically generated discriminator map contains the lowercase short name of each class as key.
Parameters
- $class : ClassMetadata
Tags
Return values
void —addInheritedEmbeddedClasses()
private
addInheritedEmbeddedClasses(ClassMetadata $subClass, ClassMetadata $parentClass) : void
Parameters
- $subClass : ClassMetadata
- $parentClass : ClassMetadata
Return values
void —addInheritedFields()
Adds inherited fields to the subclass mapping.
private
addInheritedFields(ClassMetadata $subClass, ClassMetadata $parentClass) : void
Parameters
- $subClass : ClassMetadata
- $parentClass : ClassMetadata
Return values
void —addInheritedIndexes()
Copy the table indices from the parent class superclass to the child class
private
addInheritedIndexes(ClassMetadata $subClass, ClassMetadata $parentClass) : void
Parameters
- $subClass : ClassMetadata
- $parentClass : ClassMetadata
Return values
void —addInheritedNamedNativeQueries()
Adds inherited named native queries to the subclass mapping.
private
addInheritedNamedNativeQueries(ClassMetadata $subClass, ClassMetadata $parentClass) : void
Parameters
- $subClass : ClassMetadata
- $parentClass : ClassMetadata
Return values
void —addInheritedNamedQueries()
Adds inherited named queries to the subclass mapping.
private
addInheritedNamedQueries(ClassMetadata $subClass, ClassMetadata $parentClass) : void
Parameters
- $subClass : ClassMetadata
- $parentClass : ClassMetadata
Return values
void —addInheritedRelations()
Adds inherited association mappings to the subclass mapping.
private
addInheritedRelations(ClassMetadata $subClass, ClassMetadata $parentClass) : void
Parameters
- $subClass : ClassMetadata
- $parentClass : ClassMetadata
Tags
Return values
void —addInheritedSqlResultSetMappings()
Adds inherited sql result set mappings to the subclass mapping.
private
addInheritedSqlResultSetMappings(ClassMetadata $subClass, ClassMetadata $parentClass) : void
Parameters
- $subClass : ClassMetadata
- $parentClass : ClassMetadata
Return values
void —addNestedEmbeddedClasses()
Adds nested embedded classes metadata to a parent class.
private
addNestedEmbeddedClasses(ClassMetadata $subClass, ClassMetadata $parentClass, string $prefix) : void
Parameters
- $subClass : ClassMetadata
-
Sub embedded class metadata to add nested embedded classes metadata from.
- $parentClass : ClassMetadata
-
Parent class to add nested embedded classes metadata to.
- $prefix : string
-
Embedded classes' prefix to use for nested embedded classes field names.
Return values
void —completeIdGeneratorMapping()
Completes the ID generator mapping. If "auto" is specified we choose the generator most appropriate for the targeted database platform.
private
completeIdGeneratorMapping(ClassMetadataInfo $class) : void
Parameters
- $class : ClassMetadataInfo
Tags
Return values
void —createDefaultProxyClassNameResolver()
private
createDefaultProxyClassNameResolver() : void
Return values
void —determineIdGeneratorStrategy()
private
determineIdGeneratorStrategy(AbstractPlatform $platform) : int
Parameters
- $platform : AbstractPlatform
Return values
int —getRealClass()
Gets the real class name of a class name that could be a proxy.
private
getRealClass(string $class) : string
Parameters
- $class : string
Tags
Return values
string —getShortName()
Gets the lower-case short name of a class.
private
getShortName(string $className) : string
Parameters
- $className : string
Tags
Return values
string —getTargetPlatform()
private
getTargetPlatform() : AbstractPlatform
Return values
AbstractPlatform —inheritIdGeneratorMapping()
Inherits the ID generator mapping from a parent class.
private
inheritIdGeneratorMapping(ClassMetadataInfo $class, ClassMetadataInfo $parent) : void
Parameters
- $class : ClassMetadataInfo
- $parent : ClassMetadataInfo
Return values
void —truncateSequenceName()
private
truncateSequenceName(string $schemaElementName) : string
Parameters
- $schemaElementName : string