| Total Complexity | 5 |
| Total Lines | 29 |
| Duplicated Lines | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 14 | class OperationDataType extends AbstractType |
||
| 15 | { |
||
| 16 | public function buildForm(FormBuilderInterface $builder, array $options) |
||
| 17 | { |
||
| 18 | $builder->addEventListener(FormEvents::PRE_SET_DATA, function (FormEvent $event) use ($options) { |
||
| 19 | $data = $event->getData(); |
||
| 20 | $form = $event->getForm(); |
||
| 21 | $accessor = PropertyAccess::createPropertyAccessor(); |
||
| 22 | $reflection = new \ReflectionClass($data); |
||
| 23 | |||
| 24 | foreach ($reflection->getProperties() as $property) { |
||
| 25 | if (\in_array($property->getName(), $options['exclude'])) { |
||
| 26 | continue; |
||
| 27 | } |
||
| 28 | |||
| 29 | if ($accessor->isWritable($data, $property->getName())) { |
||
| 30 | $form->add($property->getName()); |
||
| 31 | } |
||
| 32 | } |
||
| 33 | }); |
||
| 34 | } |
||
| 35 | |||
| 36 | public function configureOptions(OptionsResolver $resolver) |
||
| 43 | ; |
||
| 44 | } |
||
| 46 |