Documentation

DoctrineExtension extends AbstractDoctrineExtension
in package

DoctrineExtension is an extension for the Doctrine DBAL and ORM library.

Tags
final

since 2.9

Table of Contents

Properties

$aliasMap  : mixed
Used inside metadata driver method to simplify aggregation of data.
$drivers  : mixed
Used inside metadata driver method to simplify aggregation of data.
$annotatedClasses  : array<string|int, mixed>
$defaultConnection  : string
$processedConfigs  : array<string|int, mixed>

Methods

addAnnotatedClassesToCompile()  : mixed
Adds annotated classes to the class cache.
getAlias()  : string
Returns the recommended alias to use in XML.
getAnnotatedClassesToCompile()  : array<string|int, mixed>
Gets the annotated classes to cache.
getConfiguration()  : Configuration
{@inheritDoc}
getNamespace()  : string
getXsdValidationBasePath()  : string
load()  : void
{@inheritDoc}
loadObjectManagerCacheDriver()  : void
Loads a configured object manager metadata, query or result cache driver.
assertValidMappingConfiguration()  : mixed
Assertion if the specified mapping information is valid.
dbalLoad()  : mixed
Loads the DBAL configuration.
detectMetadataDriver()  : string|null
Detects what metadata driver to use for the supplied directory.
fixManagersAutoMappings()  : array<string|int, mixed>
Returns a modified version of $managerConfigs.
getConnectionOptions()  : array<string|int, mixed>
getMappingDriverBundleConfigDefaults()  : array<string|int, mixed>|false
If this is a bundle controlled mapping all the missing information can be autodetected by this method.
getMappingObjectDefaultName()  : string
Noun that describes the mapped objects such as Entity or Document.
getMappingResourceConfigDirectory()  : string
Relative path from the bundle root to the directory where mapping files reside.
getMappingResourceExtension()  : string
Extension used by the mapping files.
getMetadataDriverClass()  : string
The class name used by the various mapping drivers.
getObjectManagerElementName()  : string
Prefixes the relative dependency injection container path with the object manager prefix.
isConfigEnabled()  : bool
loadCacheDriver()  : string
Loads a cache driver.
loadDbalConnection()  : mixed
Loads a configured DBAL connection.
loadMappingInformation()  : mixed
loadOrmCacheDrivers()  : mixed
Loads a configured entity managers cache drivers.
loadOrmEntityManager()  : mixed
Loads a configured ORM entity manager.
loadOrmEntityManagerMappingInformation()  : mixed
Loads an ORM entity managers bundle mapping information.
loadOrmSecondLevelCache()  : mixed
Loads an ORM second level cache bundle mapping information.
ormLoad()  : mixed
Loads the Doctrine ORM configuration.
processConfiguration()  : array<string|int, mixed>
registerMappingDrivers()  : mixed
Register all the collected mapping information with the object manager by registering the appropriate mapping drivers.
setMappingDriverAlias()  : mixed
Register the alias for this mapping driver.
setMappingDriverConfig()  : mixed
Register the mapping driver configuration for later use with the object managers metadata driver chain.
createArrayAdapterCachePool()  : string
createMetadataCache()  : void
detectMappingType()  : string
Detects what mapping type to use for the supplied directory.
loadMessengerServices()  : void
loadPropertyInfoExtractor()  : void
Loads a property info extractor for each defined entity manager.
loadValidatorLoader()  : void
Loads a validator loader for each defined entity manager.
processConfigurationPrependingDefaults()  : array<string|int, mixed>
Process user configuration and adds a default DBAL connection and/or a default EM if required, then process again the configuration to get default values for each.
useMiddlewaresIfAvailable()  : void
validateAutoMapping()  : string|null
Search for a manager that is declared as 'auto_mapping' = true.

Properties

$aliasMap

Used inside metadata driver method to simplify aggregation of data.

protected mixed $aliasMap = []

$annotatedClasses

private array<string|int, mixed> $annotatedClasses = []

$processedConfigs

private array<string|int, mixed> $processedConfigs = []

Methods

addAnnotatedClassesToCompile()

Adds annotated classes to the class cache.

public addAnnotatedClassesToCompile(array<string|int, mixed> $annotatedClasses) : mixed
Parameters
$annotatedClasses : array<string|int, mixed>

An array of class patterns

getAlias()

Returns the recommended alias to use in XML.

public getAlias() : string

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.

Tags
throws
BadMethodCallException

When the extension name does not follow conventions

Return values
string

getAnnotatedClassesToCompile()

Gets the annotated classes to cache.

public getAnnotatedClassesToCompile() : array<string|int, mixed>
Return values
array<string|int, mixed>

getXsdValidationBasePath()

public getXsdValidationBasePath() : string
Return values
string

loadObjectManagerCacheDriver()

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

public loadObjectManagerCacheDriver(array<string, mixed> $objectManager, ContainerBuilder $container, string $cacheName) : void
Parameters
$objectManager : array<string, mixed>
$container : ContainerBuilder
$cacheName : string
Tags
psalm-suppress

MoreSpecificImplementedParamType

assertValidMappingConfiguration()

Assertion if the specified mapping information is valid.

protected assertValidMappingConfiguration(array<string|int, mixed> $mappingConfig, string $objectManagerName) : mixed
Parameters
$mappingConfig : array<string|int, mixed>
$objectManagerName : string
Tags
throws
InvalidArgumentException

dbalLoad()

Loads the DBAL configuration.

protected dbalLoad(array<string, mixed> $config, ContainerBuilder $container) : mixed

Usage example:

<doctrine:dbal id="myconn" dbname="sfweb" user="root" />

Parameters
$config : array<string, mixed>

An array of configuration settings

$container : ContainerBuilder

A ContainerBuilder instance

fixManagersAutoMappings()

Returns a modified version of $managerConfigs.

protected fixManagersAutoMappings(array<string|int, mixed> $managerConfigs, array<string|int, mixed> $bundles) : array<string|int, mixed>

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

Parameters
$managerConfigs : array<string|int, mixed>
$bundles : array<string|int, mixed>
Return values
array<string|int, mixed>

getConnectionOptions()

protected getConnectionOptions(array<string, mixed> $connection) : array<string|int, mixed>
Parameters
$connection : array<string, mixed>
Return values
array<string|int, mixed>

getMappingDriverBundleConfigDefaults()

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

protected getMappingDriverBundleConfigDefaults(array<string|int, mixed> $bundleConfig, ReflectionClass $bundle, ContainerBuilder $container[, string $bundleDir = null ]) : array<string|int, mixed>|false

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

Parameters
$bundleConfig : array<string|int, mixed>
$bundle : ReflectionClass
$container : ContainerBuilder
$bundleDir : string = null
Return values
array<string|int, mixed>|false

getMappingObjectDefaultName()

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

protected getMappingObjectDefaultName() : string

Will be used for autodetection of persistent objects directory.

Return values
string

getMappingResourceConfigDirectory()

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

protected getMappingResourceConfigDirectory([string|null $bundleDir = null ]) : string
Parameters
$bundleDir : string|null = null
Return values
string

getMappingResourceExtension()

Extension used by the mapping files.

protected getMappingResourceExtension() : string
Return values
string

getMetadataDriverClass()

The class name used by the various mapping drivers.

protected getMetadataDriverClass(string $driverType) : string
Parameters
$driverType : string
Return values
string

getObjectManagerElementName()

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

protected getObjectManagerElementName(mixed $name) : string
Parameters
$name : mixed
Return values
string

loadCacheDriver()

Loads a cache driver.

protected loadCacheDriver(mixed $cacheName, mixed $objectManagerName, array<string|int, mixed> $cacheDriver, ContainerBuilder $container) : string
Parameters
$cacheName : mixed
$objectManagerName : mixed
$cacheDriver : array<string|int, mixed>
$container : ContainerBuilder
Return values
string

loadDbalConnection()

Loads a configured DBAL connection.

protected loadDbalConnection(string $name, array<string, mixed> $connection, ContainerBuilder $container) : mixed
Parameters
$name : string

The name of the connection

$connection : array<string, mixed>

A dbal connection configuration.

$container : ContainerBuilder

A ContainerBuilder instance

loadMappingInformation()

protected loadMappingInformation(array<string|int, mixed> $objectManager, ContainerBuilder $container) : mixed
Parameters
$objectManager : array<string|int, mixed>

A configured object manager

$container : ContainerBuilder
Tags
throws
InvalidArgumentException

loadOrmCacheDrivers()

Loads a configured entity managers cache drivers.

protected loadOrmCacheDrivers(array<string, mixed> $entityManager, ContainerBuilder $container) : mixed
Parameters
$entityManager : array<string, mixed>

A configured ORM entity manager.

$container : ContainerBuilder

loadOrmEntityManager()

Loads a configured ORM entity manager.

protected loadOrmEntityManager(array<string, mixed> $entityManager, ContainerBuilder $container) : mixed
Parameters
$entityManager : array<string, mixed>

A configured ORM entity manager.

$container : ContainerBuilder

A ContainerBuilder instance

loadOrmEntityManagerMappingInformation()

Loads an ORM entity managers bundle mapping information.

protected loadOrmEntityManagerMappingInformation(array<string, mixed> $entityManager, Definition $ormConfigDef, ContainerBuilder $container) : mixed

There are two distinct configuration possibilities for mapping information:

  1. Specify a bundle and optionally details where the entity and mapping information reside.
  2. Specify an arbitrary mapping location.
Parameters
$entityManager : array<string, mixed>

A configured ORM entity manager

$ormConfigDef : Definition

A Definition instance

$container : ContainerBuilder

A ContainerBuilder instance

Tags
example

doctrine.orm: mappings: MyBundle1: ~ MyBundle2: yml MyBundle3: { type: annotation, dir: Entities/ } MyBundle4: { type: xml, dir: Resources/config/doctrine/mapping } MyBundle5: { type: attribute, dir: Entities/ } MyBundle6: type: yml dir: bundle-mappings/ alias: BundleAlias arbitrary_key: type: xml dir: %kernel.project_dir%/src/vendor/DoctrineExtensions/lib/DoctrineExtensions/Entities prefix: DoctrineExtensions\Entities
alias: DExt

In the case of bundles everything is really optional (which leads to autodetection for this bundle) but in the mappings key everything except alias is a required argument.

loadOrmSecondLevelCache()

Loads an ORM second level cache bundle mapping information.

protected loadOrmSecondLevelCache(array<string, mixed> $entityManager, Definition $ormConfigDef, ContainerBuilder $container) : mixed
Parameters
$entityManager : array<string, mixed>

A configured ORM entity manager

$ormConfigDef : Definition

A Definition instance

$container : ContainerBuilder

A ContainerBuilder instance

Tags
example

entity_managers: default: second_level_cache: region_lifetime: 3600 region_lock_lifetime: 60 region_cache_driver: apc log_enabled: true regions: my_service_region: type: service service : "my_service_region"

        my_query_region:
            lifetime: 300
            cache_driver: array
            type: filelock

        my_entity_region:
            lifetime: 600
            cache_driver:
                type: apc

ormLoad()

Loads the Doctrine ORM configuration.

protected ormLoad(array<string, mixed> $config, ContainerBuilder $container) : mixed

Usage example:

<doctrine:orm id="mydm" connection="myconn" />

Parameters
$config : array<string, mixed>

An array of configuration settings

$container : ContainerBuilder

A ContainerBuilder instance

processConfiguration()

protected final processConfiguration(ConfigurationInterface $configuration, array<string|int, mixed> $configs) : array<string|int, mixed>
Parameters
$configuration : ConfigurationInterface
$configs : array<string|int, mixed>
Return values
array<string|int, mixed>

registerMappingDrivers()

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

protected registerMappingDrivers(array<string|int, mixed> $objectManager, ContainerBuilder $container) : mixed
Parameters
$objectManager : array<string|int, mixed>
$container : ContainerBuilder

setMappingDriverAlias()

Register the alias for this mapping driver.

protected setMappingDriverAlias(array<string|int, mixed> $mappingConfig, string $mappingName) : mixed

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

Parameters
$mappingConfig : array<string|int, mixed>
$mappingName : string

setMappingDriverConfig()

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

protected setMappingDriverConfig(array<string|int, mixed> $mappingConfig, string $mappingName) : mixed
Parameters
$mappingConfig : array<string|int, mixed>
$mappingName : string
Tags
throws
InvalidArgumentException

createArrayAdapterCachePool()

private createArrayAdapterCachePool(ContainerBuilder $container, string $objectManagerName, string $cacheName) : string
Parameters
$container : ContainerBuilder
$objectManagerName : string
$cacheName : string
Return values
string

detectMappingType()

Detects what mapping type to use for the supplied directory.

private detectMappingType(string $directory, ContainerBuilder $container) : string
Parameters
$directory : string
$container : ContainerBuilder
Return values
string

A mapping type 'attribute' or 'annotation'

loadPropertyInfoExtractor()

Loads a property info extractor for each defined entity manager.

private loadPropertyInfoExtractor(string $entityManagerName, ContainerBuilder $container) : void
Parameters
$entityManagerName : string
$container : ContainerBuilder

loadValidatorLoader()

Loads a validator loader for each defined entity manager.

private loadValidatorLoader(string $entityManagerName, ContainerBuilder $container) : void
Parameters
$entityManagerName : string
$container : ContainerBuilder

processConfigurationPrependingDefaults()

Process user configuration and adds a default DBAL connection and/or a default EM if required, then process again the configuration to get default values for each.

private processConfigurationPrependingDefaults(ConfigurationInterface $configuration, array<string|int, array<string|int, mixed>> $configs) : array<string|int, mixed>
Parameters
$configuration : ConfigurationInterface
$configs : array<string|int, array<string|int, mixed>>
Return values
array<string|int, mixed>

useMiddlewaresIfAvailable()

private useMiddlewaresIfAvailable(ContainerBuilder $container, array<string|int, string> $connWithLogging, array<string|int, string> $connWithProfiling, array<string|int, string> $connWithBacktrace) : void
Parameters
$container : ContainerBuilder
$connWithLogging : array<string|int, string>
$connWithProfiling : array<string|int, string>
$connWithBacktrace : array<string|int, string>

validateAutoMapping()

Search for a manager that is declared as 'auto_mapping' = true.

private validateAutoMapping(array<string|int, mixed> $managerConfigs) : string|null
Parameters
$managerConfigs : array<string|int, mixed>
Tags
throws
LogicException
Return values
string|null

        
On this page

Search results