Code Coverage |
||||||||||
Classes and Traits |
Functions and Methods |
Lines |
||||||||
| Total | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
CRAP | |
0.00% |
0 / 11 |
| TextDefaultFormatter | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 11 |
| viewElements | |
0.00% |
0 / 1 |
6 | |
0.00% |
0 / 11 |
|||
| <?php | |
| /** | |
| * @file | |
| * Contains \Drupal\text\Plugin\Field\FieldFormatter\TextDefaultFormatter. | |
| */ | |
| namespace Drupal\text\Plugin\Field\FieldFormatter; | |
| use Drupal\Core\Field\FormatterBase; | |
| use Drupal\Core\Field\FieldItemListInterface; | |
| /** | |
| * Plugin implementation of the 'text_default' formatter. | |
| * | |
| * @FieldFormatter( | |
| * id = "text_default", | |
| * label = @Translation("Default"), | |
| * field_types = { | |
| * "text", | |
| * "text_long", | |
| * "text_with_summary", | |
| * }, | |
| * quickedit = { | |
| * "editor" = "plain_text" | |
| * } | |
| * ) | |
| */ | |
| class TextDefaultFormatter extends FormatterBase { | |
| /** | |
| * {@inheritdoc} | |
| */ | |
| public function viewElements(FieldItemListInterface $items, $langcode) { | |
| $elements = array(); | |
| // The ProcessedText element already handles cache context & tag bubbling. | |
| // @see \Drupal\filter\Element\ProcessedText::preRenderText() | |
| foreach ($items as $delta => $item) { | |
| $elements[$delta] = array( | |
| '#type' => 'processed_text', | |
| '#text' => $item->value, | |
| '#format' => $item->format, | |
| '#langcode' => $item->getLangcode(), | |
| ); | |
| } | |
| return $elements; | |
| } | |
| } |