abstract class AbstractClassMetadataFactory implements ClassMetadataFactory (View source)

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.

This class was abstracted from the ORM ClassMetadataFactory.

Properties

protected string $cacheSalt Salt used by specific Object Manager implementation.
protected bool $initialized
protected ReflectionService|null $reflectionService

Methods

setCacheDriver(Cache|null $cacheDriver = null)

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

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.

setReflectionService(ReflectionService $reflectionService)

Sets the reflectionService.

getReflectionService()

Gets the reflection service associated with this metadata factory.

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.

getAllMetadata()

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

getMetadataFor(string $className)

Gets the class metadata descriptor for a class.

loadMetadata(string $name, ClassMetadataBuildingContext $metadataBuildingContext)

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

isTransient($className)

{@inheritDoc}

string[]
getParentClasses(string $name)

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

onNotFoundMetadata(string $className, ClassMetadataBuildingContext $metadataBuildingContext)

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

initialize()

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

getDriver()

Returns the mapping driver implementation.

isEntity(ClassMetadata $class)

Checks whether the class metadata is an entity.

doLoadMetadata(string $className, ClassMetadata|null $parent, ClassMetadataBuildingContext $metadataBuildingContext)

Creates a new ClassMetadata instance for the given class name.

newClassMetadataBuildingContext()

Creates a new ClassMetadataBuildingContext instance.

Details

setCacheDriver(Cache|null $cacheDriver = null)

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

Parameters

Cache|null $cacheDriver

getCacheDriver()

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

ClassMetadata[] getLoadedMetadata()

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

Return Value

ClassMetadata[]

setReflectionService(ReflectionService $reflectionService)

Sets the reflectionService.

Parameters

ReflectionService $reflectionService

getReflectionService()

Gets the reflection service associated with this metadata factory.

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

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.

Exceptions

InvalidArgumentException
ReflectionException
MappingException

getMetadataFor(string $className)

Gets the class metadata descriptor for a class.

Parameters

string $className The name of the class.

Exceptions

InvalidArgumentException
ReflectionException
MappingException

protected ClassMetadata[] loadMetadata(string $name, ClassMetadataBuildingContext $metadataBuildingContext)

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 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
ClassMetadataBuildingContext $metadataBuildingContext

Return Value

ClassMetadata[]

Exceptions

InvalidArgumentException

isTransient($className)

{@inheritDoc}

Parameters

$className

protected string[] getParentClasses(string $name)

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

Parameters

string $name

Return Value

string[]

Exceptions

InvalidArgumentException

protected onNotFoundMetadata(string $className, ClassMetadataBuildingContext $metadataBuildingContext)

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
ClassMetadataBuildingContext $metadataBuildingContext

abstract protected initialize()

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

abstract protected getDriver()

Returns the mapping driver implementation.

abstract protected 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

abstract protected doLoadMetadata(string $className, ClassMetadata|null $parent, ClassMetadataBuildingContext $metadataBuildingContext)

Creates a new ClassMetadata instance for the given class name.

Parameters

string $className
ClassMetadata|null $parent
ClassMetadataBuildingContext $metadataBuildingContext

abstract protected newClassMetadataBuildingContext()

Creates a new ClassMetadataBuildingContext instance.