43 lines
2.3 KiB
YAML
43 lines
2.3 KiB
YAML
|
name: AddAutoMappingConfigurationPass
|
||
|
class_comment: "# * Injects the automapping configuration as last argument of loaders\
|
||
|
\ tagged with the \"validator.auto_mapper\" tag.\n# *\n# * @author K\xE9vin Dunglas\
|
||
|
\ <dunglas@gmail.com>"
|
||
|
dependencies:
|
||
|
- name: CompilerPassInterface
|
||
|
type: class
|
||
|
source: Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface
|
||
|
- name: ContainerBuilder
|
||
|
type: class
|
||
|
source: Symfony\Component\DependencyInjection\ContainerBuilder
|
||
|
- name: Reference
|
||
|
type: class
|
||
|
source: Symfony\Component\DependencyInjection\Reference
|
||
|
properties: []
|
||
|
methods:
|
||
|
- name: getRegexp
|
||
|
visibility: private
|
||
|
parameters:
|
||
|
- name: patterns
|
||
|
comment: "# * Injects the automapping configuration as last argument of loaders\
|
||
|
\ tagged with the \"validator.auto_mapper\" tag.\n# *\n# * @author K\xE9vin Dunglas\
|
||
|
\ <dunglas@gmail.com>\n# */\n# class AddAutoMappingConfigurationPass implements\
|
||
|
\ CompilerPassInterface\n# {\n# public function process(ContainerBuilder $container):\
|
||
|
\ void\n# {\n# if (!$container->hasParameter('validator.auto_mapping') || !$container->hasDefinition('validator.builder'))\
|
||
|
\ {\n# return;\n# }\n# \n# $config = $container->getParameter('validator.auto_mapping');\n\
|
||
|
# \n# $globalNamespaces = [];\n# $servicesToNamespaces = [];\n# foreach ($config\
|
||
|
\ as $namespace => $value) {\n# if ([] === $value['services']) {\n# $globalNamespaces[]\
|
||
|
\ = $namespace;\n# \n# continue;\n# }\n# \n# foreach ($value['services'] as $service)\
|
||
|
\ {\n# $servicesToNamespaces[$service][] = $namespace;\n# }\n# }\n# \n# $validatorBuilder\
|
||
|
\ = $container->getDefinition('validator.builder');\n# foreach ($container->findTaggedServiceIds('validator.auto_mapper')\
|
||
|
\ as $id => $tags) {\n# $regexp = $this->getRegexp(array_merge($globalNamespaces,\
|
||
|
\ $servicesToNamespaces[$id] ?? []));\n# $validatorBuilder->addMethodCall('addLoader',\
|
||
|
\ [new Reference($id)]);\n# $container->getDefinition($id)->setArgument('$classValidatorRegexp',\
|
||
|
\ $regexp);\n# }\n# \n# $container->getParameterBag()->remove('validator.auto_mapping');\n\
|
||
|
# }\n# \n# /**\n# * Builds a regexp to check if a class is auto-mapped."
|
||
|
traits:
|
||
|
- Symfony\Component\DependencyInjection\Compiler\CompilerPassInterface
|
||
|
- Symfony\Component\DependencyInjection\ContainerBuilder
|
||
|
- Symfony\Component\DependencyInjection\Reference
|
||
|
interfaces:
|
||
|
- CompilerPassInterface
|