RegisterMappingsPass
abstract class RegisterMappingsPass implements CompilerPassInterface
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 that are easy to use, see the RegisterXyMappingsPass classes in the DoctrineBundle resp. DoctrineMongodbBundle, DoctrineCouchdbBundle and DoctrinePhpcrBundle.
Properties
| protected Definition|Reference | $driver | DI object for the driver to use, either a service definition for a private service or a reference for a public service. | |
| protected string[] | $namespaces | List of namespaces handled by the driver. | |
| protected string[] | $managerParameters | List of potential container parameters that hold the object manager name to register the mappings with the correct metadata driver, for example array('acme.manager', 'doctrine.default_entity_manager'). | |
| protected string | $driverPattern | Naming pattern of the metadata chain driver service ids, for example 'doctrine.orm.%s_metadata_driver'. | |
| protected string|false | $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. |
Methods
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.
Get the service name of the metadata chain driver that the mappings should be registered with.
Determine whether this mapping should be activated or not. This allows to take this decision with the container builder available.
Details
__construct(Definition|Reference $driver, array $namespaces, array $managerParameters, string $driverPattern, string|false $enabledParameter = false, string $configurationPattern = '', string $registerAliasMethodName = '', array $aliasMap = array())
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.
The $aliasMap parameter can be used to define bundle namespace shortcuts like the DoctrineBundle provides automatically for objects in the default Entity/Document folder.
protected string
getChainDriverServiceName(ContainerBuilder $container)
Get the service name of the metadata chain driver that the mappings should be registered with.
protected Definition|Reference
getDriver(ContainerBuilder $container)
Create the service definition for the metadata driver.
protected bool
enabled(ContainerBuilder $container)
Determine whether this mapping should be activated or not. This allows to take this decision with the container builder available.
This default implementation checks if the class has the enabledParameter configured and if so if that parameter is present in the container.