abstract class AbstractClassMetadataFactory implements ClassMetadataFactory (View source)

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.

Properties

protected string $cacheSalt Salt used by specific Object Manager implementation.
protected bool $initialized

Methods

void
setCacheDriver(Cache|null $cacheDriver = null)

Sets the cache driver used by the factory to cache ClassMetadata instances.

Cache|null
getCacheDriver()

Gets the cache driver used by the factory to cache ClassMetadata instances.

getLoadedMetadata()

Returns an array of all the loaded metadata currently in memory.

getAllMetadata()

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

void
initialize()

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

string
getFqcnFromAlias(string $namespaceAlias, string $simpleClassName)

Gets the fully qualified class-name from the namespace alias.

getDriver()

Returns the mapping driver implementation.

void
wakeupReflection(ClassMetadata $class, ReflectionService $reflService)

Wakes up reflection after ClassMetadata gets unserialized from cache.

void
initializeReflection(ClassMetadata $class, ReflectionService $reflService)

Initializes Reflection after ClassMetadata was constructed.

bool
isEntity(ClassMetadata $class)

Checks whether the class metadata is an entity.

getMetadataFor(string $className)

Gets the class metadata descriptor for a class.

bool
hasMetadataFor(string $className)

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

setMetadataFor(string $className, ClassMetadata $class)

Sets the metadata descriptor for a specific class.

string[]
getParentClasses(string $name)

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

string[]
loadMetadata(string $name)

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

onNotFoundMetadata(string $className)

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

void
doLoadMetadata(ClassMetadata $class, ClassMetadata|null $parent, bool $rootEntityFound, array $nonSuperclassParents)

Actually loads the metadata from the underlying metadata.

newClassMetadataInstance(string $className)

Creates a new ClassMetadata instance for the given class name.

bool
isTransient($class)

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

void
setReflectionService(ReflectionService $reflectionService)

Sets the reflectionService.

getReflectionService()

Gets the reflection service associated with this metadata factory.

Details

void setCacheDriver(Cache|null $cacheDriver = null)

Sets the cache driver used by the factory to cache ClassMetadata instances.

Parameters

Cache|null $cacheDriver

Return Value

void

Cache|null getCacheDriver()

Gets the cache driver used by the factory to cache ClassMetadata instances.

Return Value

Cache|null

ClassMetadata[] getLoadedMetadata()

Returns an array of all the loaded metadata currently in memory.

Return Value

ClassMetadata[]

ClassMetadata[] getAllMetadata()

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

Return Value

ClassMetadata[] The ClassMetadata instances of all mapped classes.

abstract protected void initialize()

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

Return Value

void

abstract protected string getFqcnFromAlias(string $namespaceAlias, string $simpleClassName)

Gets the fully qualified class-name from the namespace alias.

Parameters

string $namespaceAlias
string $simpleClassName

Return Value

string

abstract protected MappingDriver getDriver()

Returns the mapping driver implementation.

Return Value

MappingDriver

abstract protected void wakeupReflection(ClassMetadata $class, ReflectionService $reflService)

Wakes up reflection after ClassMetadata gets unserialized from cache.

Parameters

ClassMetadata $class
ReflectionService $reflService

Return Value

void

abstract protected void initializeReflection(ClassMetadata $class, ReflectionService $reflService)

Initializes Reflection after ClassMetadata was constructed.

Parameters

ClassMetadata $class
ReflectionService $reflService

Return Value

void

abstract protected bool isEntity(ClassMetadata $class)

Checks whether the class metadata is an entity.

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

Parameters

ClassMetadata $class

Return Value

bool

ClassMetadata getMetadataFor(string $className)

Gets the class metadata descriptor for a class.

Parameters

string $className The name of the class.

Return Value

ClassMetadata

Exceptions

ReflectionException
MappingException

bool hasMetadataFor(string $className)

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

Parameters

string $className

Return Value

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

setMetadataFor(string $className, ClassMetadata $class)

Sets the metadata descriptor for a specific class.

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

Parameters

string $className
ClassMetadata $class

protected string[] getParentClasses(string $name)

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

Parameters

string $name

Return Value

string[]

protected string[] loadMetadata(string $name)

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

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 {see Doctrine\Common\Persistence\Mapping\ReflectionService} interface should be used for reflection.

Parameters

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

Return Value

string[]

protected ClassMetadata|null onNotFoundMetadata(string $className)

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

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

Parameters

string $className

Return Value

ClassMetadata|null

abstract protected void doLoadMetadata(ClassMetadata $class, ClassMetadata|null $parent, bool $rootEntityFound, array $nonSuperclassParents)

Actually loads the metadata from the underlying metadata.

Parameters

ClassMetadata $class
ClassMetadata|null $parent
bool $rootEntityFound
array $nonSuperclassParents All parent class names that are not marked as mapped superclasses.

Return Value

void

abstract protected ClassMetadata newClassMetadataInstance(string $className)

Creates a new ClassMetadata instance for the given class name.

Parameters

string $className

Return Value

ClassMetadata

bool isTransient($class)

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

This is only the case if it is either mapped directly or as a MappedSuperclass.

Parameters

$class

Return Value

bool

void setReflectionService(ReflectionService $reflectionService)

Sets the reflectionService.

Parameters

ReflectionService $reflectionService

Return Value

void

ReflectionService getReflectionService()

Gets the reflection service associated with this metadata factory.

Return Value

ReflectionService