| Conditions | 4 |
| Paths | 4 |
| Total Lines | 29 |
| Code Lines | 15 |
| Lines | 0 |
| Ratio | 0 % |
| Tests | 16 |
| CRAP Score | 4 |
| Changes | 0 | ||
| 1 | <?php |
||
| 12 | 4 | public function process(ContainerBuilder $container) |
|
| 13 | { |
||
| 14 | 4 | if (!$container->has('lag.admin.field_factory')) { |
|
| 15 | 1 | return; |
|
| 16 | } |
||
| 17 | // get field factory definition |
||
| 18 | 3 | $definition = $container->findDefinition( |
|
| 19 | 3 | 'lag.admin.field_factory' |
|
| 20 | ); |
||
| 21 | // find field tagged services |
||
| 22 | 3 | $taggedServices = $container->findTaggedServiceIds( |
|
| 23 | 3 | 'lag.field' |
|
| 24 | ); |
||
| 25 | // foreach tagged, with add this field type to the field factory |
||
| 26 | 3 | foreach ($taggedServices as $id => $tags) { |
|
| 27 | 2 | if (empty($tags[0]['type'])) { |
|
| 28 | 1 | throw new InvalidConfigurationException('You should defined a "type" attribute for field tag for service '.$id); |
|
| 29 | } |
||
| 30 | // add allowed field type to the field factory |
||
| 31 | 1 | $definition->addMethodCall('addFieldMapping', [ |
|
| 32 | 1 | $tags[0]['type'], $id, |
|
| 33 | ]); |
||
| 34 | // add application configuration for field |
||
| 35 | 1 | $tagDefinition = $container->findDefinition($id); |
|
| 36 | 1 | $tagDefinition->addMethodCall('setConfiguration', [ |
|
| 37 | 1 | new Reference('lag.admin.application'), |
|
| 38 | ]); |
||
| 39 | } |
||
| 40 | 2 | } |
|
| 41 | } |
||
| 42 |