| 1 | <?php |
||
| 21 | final class StringFieldType implements FieldTypeInterface |
||
| 22 | { |
||
| 23 | /** |
||
| 24 | * @var DataExtractorInterface |
||
| 25 | */ |
||
| 26 | private $dataExtractor; |
||
| 27 | |||
| 28 | /** |
||
| 29 | * @param DataExtractorInterface $dataExtractor |
||
| 30 | */ |
||
| 31 | public function __construct(DataExtractorInterface $dataExtractor) |
||
| 35 | |||
| 36 | /** |
||
| 37 | * {@inheritdoc} |
||
| 38 | */ |
||
| 39 | public function render(Field $field, $data, array $options) |
||
| 40 | { |
||
| 41 | $value = $this->dataExtractor->get($field, $data); |
||
| 42 | |||
| 43 | return is_string($value) ? htmlspecialchars($value) : $value; |
||
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
| 47 | * {@inheritdoc} |
||
| 48 | */ |
||
| 49 | public function configureOptions(OptionsResolver $resolver) |
||
| 50 | { |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * {@inheritdoc} |
||
| 55 | */ |
||
| 56 | public function getName() |
||
| 60 | |||
| 61 | /** |
||
| 62 | * {@inheritdoc} |
||
| 63 | */ |
||
| 64 | public function getBlockPrefix() |
||
| 68 | } |
||
| 69 |