These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | |||
3 | declare(strict_types=1); |
||
4 | |||
5 | namespace Netgen\Bundle\EzFormsBundle\Form\FieldTypeHandler; |
||
6 | |||
7 | use eZ\Publish\API\Repository\Values\Content\Content; |
||
8 | use eZ\Publish\API\Repository\Values\ContentType\FieldDefinition; |
||
9 | use eZ\Publish\Core\FieldType\TextBlock\Value as TextBlockValue; |
||
10 | use eZ\Publish\SPI\FieldType\Value; |
||
11 | use Netgen\Bundle\EzFormsBundle\Form\FieldTypeHandler; |
||
12 | use Symfony\Component\Form\Extension\Core\Type\TextareaType; |
||
13 | use Symfony\Component\Form\FormBuilderInterface; |
||
14 | |||
15 | class TextBlock extends FieldTypeHandler |
||
16 | { |
||
17 | public function convertFieldValueToForm(Value $value, ?FieldDefinition $fieldDefinition = null): string |
||
18 | { |
||
19 | return $value->text; |
||
0 ignored issues
–
show
|
|||
20 | } |
||
21 | |||
22 | public function convertFieldValueFromForm($data): TextBlockValue |
||
23 | { |
||
24 | if (empty($data)) { |
||
25 | $data = ''; |
||
26 | } |
||
27 | |||
28 | return new TextBlockValue($data); |
||
29 | } |
||
30 | |||
31 | protected function buildFieldForm( |
||
32 | FormBuilderInterface $formBuilder, |
||
33 | FieldDefinition $fieldDefinition, |
||
34 | string $languageCode, |
||
35 | ?Content $content = null |
||
36 | ): void { |
||
37 | $options = $this->getDefaultFieldOptions($fieldDefinition, $languageCode, $content); |
||
38 | |||
39 | $options['attr']['rows'] = $fieldDefinition->fieldSettings['textRows']; |
||
40 | |||
41 | $formBuilder->add($fieldDefinition->identifier, TextareaType::class, $options); |
||
42 | } |
||
43 | } |
||
44 |
If you access a property on an interface, you most likely code against a concrete implementation of the interface.
Available Fixes
Adding an additional type check:
Changing the type hint: