class DisconnectedClassMetadataFactory extends ClassMetadataFactory (View source)

The DisconnectedClassMetadataFactory is used to create ClassMetadata objects that do not require the entity class actually exist. This allows us to load some mapping information and use it to do things like generate code from the mapping information.

Properties

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

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.

completeRuntimeMetadata(ClassMetadata $class, ClassMetadata|null $parent = null)

No description

validateRuntimeMetadata(ClassMetadata $class, ClassMetadata|null $parent = null)

Validate runtime metadata is correctly defined.

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

protected initialize()

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

protected getDriver()

Returns the mapping driver implementation.

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

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

protected newClassMetadataBuildingContext()

Creates a new ClassMetadataBuildingContext instance.

setEntityManager(EntityManagerInterface $em)

Parameters

EntityManagerInterface $em

protected completeRuntimeMetadata(ClassMetadata $class, ClassMetadata|null $parent = null)

Parameters

ClassMetadata $class
ClassMetadata|null $parent

protected validateRuntimeMetadata(ClassMetadata $class, ClassMetadata|null $parent = null)

Validate runtime metadata is correctly defined.

Parameters

ClassMetadata $class
ClassMetadata|null $parent

Exceptions

MappingException