Documentation

RegisterMappingsPass
in package
implements CompilerPassInterface

AbstractYes

Base class for the doctrine bundles to provide a compiler pass class that helps to register doctrine mappings.

The compiler pass is meant to register the mappings with the metadata chain driver corresponding to one of the object managers.

For concrete implementations, see the RegisterXyMappingsPass classes in the DoctrineBundle resp. DoctrineMongodbBundle, DoctrineCouchdbBundle and DoctrinePhpcrBundle.

Tags
author

David Buchmann david@liip.ch

Table of Contents

Interfaces

CompilerPassInterface
Interface that must be implemented by compilation passes.

Properties

$driver  : Definition|Reference
DI object for the driver to use, either a service definition for a private service or a reference for a public service.
$driverPattern  : string
Naming pattern of the metadata chain driver service ids, for example 'doctrine.orm.%s_metadata_driver'.
$enabledParameter  : string|false
A name for a parameter in the container. If set, this compiler pass will only do anything if the parameter is present. (But regardless of the value of that parameter.
$managerParameters  : array<string|int, string>
List of potential container parameters that hold the object manager name to register the mappings with the correct metadata driver, for example ['acme.manager', 'doctrine.default_entity_manager'].
$namespaces  : array<string|int, string>
List of namespaces handled by the driver.
$aliasMap  : array<string|int, string>
Map of alias to namespace.
$configurationPattern  : string
Naming pattern for the configuration service id, for example 'doctrine.orm.%s_configuration'.
$registerAliasMethodName  : string
Method name to call on the configuration service. This depends on the Doctrine implementation. For example addEntityNamespace.

Methods

__construct()  : mixed
The $managerParameters is an ordered list of container parameters that could provide the name of the manager to register these namespaces and alias on. The first non-empty name is used, the others skipped.
process()  : mixed
Register mappings and alias with the metadata drivers.
enabled()  : bool
Determine whether this mapping should be activated or not. This allows to take this decision with the container builder available.
getChainDriverServiceName()  : string
Get the service name of the metadata chain driver that the mappings should be registered with.
getDriver()  : Definition|Reference
Create the service definition for the metadata driver.
getConfigurationServiceName()  : string
Get the service name from the pattern and the configured manager name.
getManagerName()  : string
Determine the manager name.

Properties

$driverPattern

Naming pattern of the metadata chain driver service ids, for example 'doctrine.orm.%s_metadata_driver'.

protected string $driverPattern

$enabledParameter

A name for a parameter in the container. If set, this compiler pass will only do anything if the parameter is present. (But regardless of the value of that parameter.

protected string|false $enabledParameter

$managerParameters

List of potential container parameters that hold the object manager name to register the mappings with the correct metadata driver, for example ['acme.manager', 'doctrine.default_entity_manager'].

protected array<string|int, string> $managerParameters

$namespaces

List of namespaces handled by the driver.

protected array<string|int, string> $namespaces

$configurationPattern

Naming pattern for the configuration service id, for example 'doctrine.orm.%s_configuration'.

private string $configurationPattern

$registerAliasMethodName

Method name to call on the configuration service. This depends on the Doctrine implementation. For example addEntityNamespace.

private string $registerAliasMethodName

Methods

__construct()

The $managerParameters is an ordered list of container parameters that could provide the name of the manager to register these namespaces and alias on. The first non-empty name is used, the others skipped.

public __construct(Definition|Reference $driver, array<string|int, string> $namespaces, array<string|int, string> $managerParameters, string $driverPattern[, string|false $enabledParameter = false ][, string $configurationPattern = '' ][, string $registerAliasMethodName = '' ][, array<string|int, string> $aliasMap = [] ]) : mixed

The $aliasMap parameter can be used to define bundle namespace shortcuts like the DoctrineBundle provides automatically for objects in the default Entity/Document folder.

Parameters
$driver : Definition|Reference

Driver DI definition or reference

$namespaces : array<string|int, string>

List of namespaces handled by $driver

$managerParameters : array<string|int, string>

list of container parameters that could hold the manager name

$driverPattern : string

Pattern for the metadata driver service name

$enabledParameter : string|false = false

Service container parameter that must be present to enable the mapping. Set to false to not do any check, optional.

$configurationPattern : string = ''

Pattern for the Configuration service name

$registerAliasMethodName : string = ''

Name of Configuration class method to register alias

$aliasMap : array<string|int, string> = []

Map of alias to namespace

enabled()

Determine whether this mapping should be activated or not. This allows to take this decision with the container builder available.

protected enabled(ContainerBuilder $container) : bool

This default implementation checks if the class has the enabledParameter configured and if so if that parameter is present in the container.

Parameters
$container : ContainerBuilder
Return values
bool

getManagerName()

Determine the manager name.

private getManagerName(ContainerBuilder $container) : string

The default implementation loops over the managerParameters and returns the first non-empty parameter.

Parameters
$container : ContainerBuilder
Tags
throws
InvalidArgumentException

if none of the managerParameters is found in the container

Return values
string

        
On this page

Search results