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