W3cubDocs

/Symfony 4.1

AbstractDoctrineExtension

abstract class AbstractDoctrineExtension extends Extension

This abstract classes groups common code that Doctrine Object Manager extensions (ORM, MongoDB, CouchDB) need.

Properties

protected $aliasMap Used inside metadata driver method to simplify aggregation of data.
protected $drivers Used inside metadata driver method to simplify aggregation of data.

Methods

string getXsdValidationBasePath()

Returns the base path for the XSD files.

from Extension
string getNamespace()

Returns the namespace to be used for this extension (XML namespace).

from Extension
string getAlias()

Returns the recommended alias to use in XML.

from Extension
ConfigurationInterface|null getConfiguration(array $config, ContainerBuilder $container)

Returns extension configuration.

from Extension
processConfiguration(ConfigurationInterface $configuration, array $configs) from Extension
getProcessedConfigs() from Extension
bool isConfigEnabled(ContainerBuilder $container, array $config) from Extension
array getAnnotatedClassesToCompile()

Gets the annotated classes to cache.

from Extension
addAnnotatedClassesToCompile(array $annotatedClasses)

Adds annotated classes to the class cache.

from Extension
loadMappingInformation(array $objectManager, ContainerBuilder $container)
setMappingDriverAlias(array $mappingConfig, string $mappingName)

Register the alias for this mapping driver.

setMappingDriverConfig(array $mappingConfig, string $mappingName)

Register the mapping driver configuration for later use with the object managers metadata driver chain.

array|false getMappingDriverBundleConfigDefaults(array $bundleConfig, ReflectionClass $bundle, ContainerBuilder $container)

If this is a bundle controlled mapping all the missing information can be autodetected by this method.

registerMappingDrivers(array $objectManager, ContainerBuilder $container)

Register all the collected mapping information with the object manager by registering the appropriate mapping drivers.

assertValidMappingConfiguration(array $mappingConfig, string $objectManagerName)

Assertion if the specified mapping information is valid.

string|null detectMetadataDriver(string $dir, ContainerBuilder $container)

Detects what metadata driver to use for the supplied directory.

loadObjectManagerCacheDriver(array $objectManager, ContainerBuilder $container, string $cacheName)

Loads a configured object manager metadata, query or result cache driver.

string loadCacheDriver(string $cacheName, string $objectManagerName, array $cacheDriver, ContainerBuilder $container)

Loads a cache driver.

array fixManagersAutoMappings(array $managerConfigs, array $bundles)

Returns a modified version of $managerConfigs.

string getObjectManagerElementName(string $name)

Prefixes the relative dependency injection container path with the object manager prefix.

string getMappingObjectDefaultName()

Noun that describes the mapped objects such as Entity or Document.

string getMappingResourceConfigDirectory()

Relative path from the bundle root to the directory where mapping files reside.

string getMappingResourceExtension()

Extension used by the mapping files.

Details

string getXsdValidationBasePath()

Returns the base path for the XSD files.

Return Value

string The XSD base path

string getNamespace()

Returns the namespace to be used for this extension (XML namespace).

Return Value

string The XML namespace

string getAlias()

Returns the recommended alias to use in XML.

This alias is also the mandatory prefix to use when using YAML.

This convention is to remove the "Extension" postfix from the class name and then lowercase and underscore the result. So:

AcmeHelloExtension

becomes

acme_hello

This can be overridden in a sub-class to specify the alias manually.

Return Value

string The alias

Exceptions

BadMethodCallException When the extension name does not follow conventions

ConfigurationInterface|null getConfiguration(array $config, ContainerBuilder $container)

Returns extension configuration.

Parameters

array $config
ContainerBuilder $container

Return Value

ConfigurationInterface|null The configuration or null

final protected processConfiguration(ConfigurationInterface $configuration, array $configs)

Parameters

ConfigurationInterface $configuration
array $configs

final getProcessedConfigs()

protected bool isConfigEnabled(ContainerBuilder $container, array $config)

Parameters

ContainerBuilder $container
array $config

Return Value

bool Whether the configuration is enabled

Exceptions

InvalidArgumentException When the config is not enableable

array getAnnotatedClassesToCompile()

Gets the annotated classes to cache.

Return Value

array An array of classes

addAnnotatedClassesToCompile(array $annotatedClasses)

Adds annotated classes to the class cache.

Parameters

array $annotatedClasses An array of class patterns

protected loadMappingInformation(array $objectManager, ContainerBuilder $container)

Parameters

array $objectManager A configured object manager
ContainerBuilder $container A ContainerBuilder instance

Exceptions

InvalidArgumentException

protected setMappingDriverAlias(array $mappingConfig, string $mappingName)

Register the alias for this mapping driver.

Aliases can be used in the Query languages of all the Doctrine object managers to simplify writing tasks.

Parameters

array $mappingConfig
string $mappingName

protected setMappingDriverConfig(array $mappingConfig, string $mappingName)

Register the mapping driver configuration for later use with the object managers metadata driver chain.

Parameters

array $mappingConfig
string $mappingName

Exceptions

InvalidArgumentException

protected array|false getMappingDriverBundleConfigDefaults(array $bundleConfig, ReflectionClass $bundle, ContainerBuilder $container)

If this is a bundle controlled mapping all the missing information can be autodetected by this method.

Returns false when autodetection failed, an array of the completed information otherwise.

Parameters

array $bundleConfig
ReflectionClass $bundle
ContainerBuilder $container

Return Value

array|false

protected registerMappingDrivers(array $objectManager, ContainerBuilder $container)

Register all the collected mapping information with the object manager by registering the appropriate mapping drivers.

Parameters

array $objectManager
ContainerBuilder $container A ContainerBuilder instance

protected assertValidMappingConfiguration(array $mappingConfig, string $objectManagerName)

Assertion if the specified mapping information is valid.

Parameters

array $mappingConfig
string $objectManagerName

Exceptions

InvalidArgumentException

protected string|null detectMetadataDriver(string $dir, ContainerBuilder $container)

Detects what metadata driver to use for the supplied directory.

Parameters

string $dir A directory path
ContainerBuilder $container A ContainerBuilder instance

Return Value

string|null A metadata driver short name, if one can be detected

protected loadObjectManagerCacheDriver(array $objectManager, ContainerBuilder $container, string $cacheName)

Loads a configured object manager metadata, query or result cache driver.

Parameters

array $objectManager A configured object manager
ContainerBuilder $container A ContainerBuilder instance
string $cacheName

Exceptions

InvalidArgumentException in case of unknown driver type

protected string loadCacheDriver(string $cacheName, string $objectManagerName, array $cacheDriver, ContainerBuilder $container)

Loads a cache driver.

Parameters

string $cacheName The cache driver name
string $objectManagerName The object manager name
array $cacheDriver The cache driver mapping
ContainerBuilder $container The ContainerBuilder instance

Return Value

string

Exceptions

InvalidArgumentException

protected array fixManagersAutoMappings(array $managerConfigs, array $bundles)

Returns a modified version of $managerConfigs.

The manager called $autoMappedManager will map all bundles that are not mapped by other managers.

Parameters

array $managerConfigs
array $bundles

Return Value

array The modified version of $managerConfigs

abstract protected string getObjectManagerElementName(string $name)

Prefixes the relative dependency injection container path with the object manager prefix.

Parameters

string $name

Return Value

string

abstract protected string getMappingObjectDefaultName()

Noun that describes the mapped objects such as Entity or Document.

Will be used for autodetection of persistent objects directory.

Return Value

string

abstract protected string getMappingResourceConfigDirectory()

Relative path from the bundle root to the directory where mapping files reside.

Return Value

string

abstract protected string getMappingResourceExtension()

Extension used by the mapping files.

Return Value

string