DoctrineOrmMappingsPass
extends RegisterMappingsPass
in package
Class for Symfony bundles to configure mappings for model classes not in the auto-mapped folder.
NOTE: alias is only supported by Symfony 2.6+ and will be ignored with older versions.
Table of Contents
- $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.
- __construct() : mixed
- You should not directly instantiate this class but use one of the factory methods.
- createAnnotationMappingDriver() : self
- createAttributeMappingDriver() : self
- createPhpMappingDriver() : self
- createStaticPhpMappingDriver() : self
- createXmlMappingDriver() : self
- createYamlMappingDriver() : self
- 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
$driver
DI object for the driver to use, either a service definition for a private service or a reference for a public service.
protected
Definition|Reference
$driver
$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
$aliasMap
Map of alias to namespace.
private
array<string|int, string>
$aliasMap
$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()
You should not directly instantiate this class but use one of the factory methods.
public
__construct(Definition|Reference $driver, array<string|int, string> $namespaces, array<string|int, string> $managerParameters[, string|false $enabledParameter = false ][, array<string|int, string> $aliasMap = [] ]) : mixed
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>
-
Ordered list of container parameters that could hold the manager name. doctrine.default_entity_manager is appended automatically.
- $enabledParameter : string|false = false
-
If specified, the compiler pass only executes if this parameter is defined in the service container.
- $aliasMap : array<string|int, string> = []
-
Map of alias to namespace.
Return values
mixed —createAnnotationMappingDriver()
public
static createAnnotationMappingDriver(array<string|int, string> $namespaces, array<string|int, string> $directories[, array<string|int, string> $managerParameters = [] ][, string|false $enabledParameter = false ][, array<string|int, string> $aliasMap = [] ]) : self
Parameters
- $namespaces : array<string|int, string>
-
List of namespaces that are handled with annotation mapping
- $directories : array<string|int, string>
-
List of directories to look for annotated classes
- $managerParameters : array<string|int, string> = []
-
List of parameters that could which object manager name your bundle uses. This compiler pass will automatically append the parameter name for the default entity manager to this list.
- $enabledParameter : string|false = false
-
Service container parameter that must be present to enable the mapping. Set to false to not do any check, optional.
- $aliasMap : array<string|int, string> = []
-
Map of alias to namespace.
Return values
self —createAttributeMappingDriver()
public
static createAttributeMappingDriver(array<string|int, string> $namespaces, array<string|int, string> $directories[, array<string|int, string> $managerParameters = [] ][, string|false $enabledParameter = false ][, array<string|int, string> $aliasMap = [] ]) : self
Parameters
- $namespaces : array<string|int, string>
-
List of namespaces that are handled with annotation mapping
- $directories : array<string|int, string>
-
List of directories to look for annotated classes
- $managerParameters : array<string|int, string> = []
-
List of parameters that could which object manager name your bundle uses. This compiler pass will automatically append the parameter name for the default entity manager to this list.
- $enabledParameter : string|false = false
-
Service container parameter that must be present to enable the mapping. Set to false to not do any check, optional.
- $aliasMap : array<string|int, string> = []
-
Map of alias to namespace.
Return values
self —createPhpMappingDriver()
public
static createPhpMappingDriver(array<string|int, string> $namespaces[, array<string|int, string> $managerParameters = [] ][, string|false $enabledParameter = false ][, array<string|int, string> $aliasMap = [] ]) : self
Parameters
- $namespaces : array<string|int, string>
-
Hashmap of directory path to namespace
- $managerParameters : array<string|int, string> = []
-
List of parameters that could which object manager name your bundle uses. This compiler pass will automatically append the parameter name for the default entity manager to this list.
- $enabledParameter : string|false = false
-
Service container parameter that must be present to enable the mapping. Set to false to not do any check, optional.
- $aliasMap : array<string|int, string> = []
-
Map of alias to namespace.
Return values
self —createStaticPhpMappingDriver()
public
static createStaticPhpMappingDriver(array<string|int, string> $namespaces, array<string|int, string> $directories[, array<string|int, string> $managerParameters = [] ][, string|false $enabledParameter = false ][, array<string|int, string> $aliasMap = [] ]) : self
Parameters
- $namespaces : array<string|int, string>
-
List of namespaces that are handled with static php mapping
- $directories : array<string|int, string>
-
List of directories to look for static php mapping files
- $managerParameters : array<string|int, string> = []
-
List of parameters that could which object manager name your bundle uses. This compiler pass will automatically append the parameter name for the default entity manager to this list.
- $enabledParameter : string|false = false
-
Service container parameter that must be present to enable the mapping. Set to false to not do any check, optional.
- $aliasMap : array<string|int, string> = []
-
Map of alias to namespace.
Return values
self —createXmlMappingDriver()
public
static createXmlMappingDriver(array<string|int, string> $namespaces[, array<string|int, string> $managerParameters = [] ][, string|false $enabledParameter = false ][, array<string|int, string> $aliasMap = [] ]) : self
Parameters
- $namespaces : array<string|int, string>
-
Hashmap of directory path to namespace.
- $managerParameters : array<string|int, string> = []
-
List of parameters that could which object manager name your bundle uses. This compiler pass will automatically append the parameter name for the default entity manager to this list.
- $enabledParameter : string|false = false
-
Service container parameter that must be present to enable the mapping. Set to false to not do any check, optional.
- $aliasMap : array<string|int, string> = []
-
Map of alias to namespace.
Return values
self —createYamlMappingDriver()
public
static createYamlMappingDriver(array<string|int, string> $namespaces[, array<string|int, string> $managerParameters = [] ][, string|false $enabledParameter = false ][, array<string|int, string> $aliasMap = [] ]) : self
Parameters
- $namespaces : array<string|int, string>
-
Hashmap of directory path to namespace
- $managerParameters : array<string|int, string> = []
-
List of parameters that could which object manager name your bundle uses. This compiler pass will automatically append the parameter name for the default entity manager to this list.
- $enabledParameter : string|false = false
-
Service container parameter that must be present to enable the mapping. Set to false to not do any check, optional.
- $aliasMap : array<string|int, string> = []
-
Map of alias to namespace.
Return values
self —process()
Register mappings and alias with the metadata drivers.
public
process(ContainerBuilder $container) : mixed
Parameters
- $container : ContainerBuilder
Return values
mixed —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 —whether this compiler pass really should register the mappings
getChainDriverServiceName()
Get the service name of the metadata chain driver that the mappings should be registered with.
protected
getChainDriverServiceName(ContainerBuilder $container) : string
Parameters
- $container : ContainerBuilder
Tags
Return values
string —The name of the chain driver service
getDriver()
Create the service definition for the metadata driver.
protected
getDriver(ContainerBuilder $container) : Definition|Reference
Parameters
- $container : ContainerBuilder
-
Passed on in case an extending class needs access to the container
Return values
Definition|Reference —the metadata driver to add to all chain drivers
getConfigurationServiceName()
Get the service name from the pattern and the configured manager name.
private
getConfigurationServiceName(ContainerBuilder $container) : string
Parameters
- $container : ContainerBuilder
Tags
Return values
string —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