Conditions | 3 |
Paths | 3 |
Total Lines | 19 |
Code Lines | 7 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
1 | <?php |
||
20 | public function buildView(FormView $view, FormInterface $form, array $options) |
||
21 | { |
||
22 | |||
23 | if(isset($options['image_property'])){ |
||
24 | |||
25 | // this will be whatever class/entity is bound to your form (e.g. Media) |
||
26 | $parentData = $form->getParent()->getData(); |
||
27 | |||
28 | $imageUrl = null; |
||
29 | |||
30 | if (null !== $parentData) { |
||
31 | $accessor = PropertyAccess::createPropertyAccessor(); |
||
32 | |||
33 | $imageUrl = $accessor->getValue($parentData, $options['image_property']); |
||
34 | |||
35 | } |
||
36 | |||
37 | // sets an "image_url" variable that will be available when rendering this field |
||
38 | $view->vars['image_url'] = $imageUrl; |
||
39 | } |
||
45 | } |