class TextDefaultFormatter
Same name and namespace in other branches
- 11.x core/modules/text/src/Plugin/Field/FieldFormatter/TextDefaultFormatter.php \Drupal\text\Plugin\Field\FieldFormatter\TextDefaultFormatter
- 9 core/modules/text/src/Plugin/Field/FieldFormatter/TextDefaultFormatter.php \Drupal\text\Plugin\Field\FieldFormatter\TextDefaultFormatter
- 8.9.x core/modules/text/src/Plugin/Field/FieldFormatter/TextDefaultFormatter.php \Drupal\text\Plugin\Field\FieldFormatter\TextDefaultFormatter
- main core/modules/text/src/Plugin/Field/FieldFormatter/TextDefaultFormatter.php \Drupal\text\Plugin\Field\FieldFormatter\TextDefaultFormatter
Plugin implementation of the 'text_default' formatter.
Attributes
#[FieldFormatter(id: 'text_default', label: new TranslatableMarkup('Default'), field_types: [
'text',
'text_long',
'text_with_summary',
])]
Hierarchy
- class \Drupal\Component\Plugin\PluginBase implements \Drupal\Component\Plugin\PluginInspectionInterface, \Drupal\Component\Plugin\DerivativeInspectionInterface
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait extends \Drupal\Component\Plugin\PluginBase
- class \Drupal\Core\Field\PluginSettingsBase implements \Drupal\Core\Field\PluginSettingsInterface, \Drupal\Component\Plugin\DependentPluginInterface extends \Drupal\Core\Plugin\PluginBase
- class \Drupal\Core\Field\FormatterBase implements \Drupal\Core\Field\FormatterInterface, \Drupal\Core\Plugin\ContainerFactoryPluginInterface extends \Drupal\Core\Field\PluginSettingsBase
- class \Drupal\text\Plugin\Field\FieldFormatter\TextDefaultFormatter extends \Drupal\Core\Field\FormatterBase
- class \Drupal\Core\Field\FormatterBase implements \Drupal\Core\Field\FormatterInterface, \Drupal\Core\Plugin\ContainerFactoryPluginInterface extends \Drupal\Core\Field\PluginSettingsBase
- class \Drupal\Core\Field\PluginSettingsBase implements \Drupal\Core\Field\PluginSettingsInterface, \Drupal\Component\Plugin\DependentPluginInterface extends \Drupal\Core\Plugin\PluginBase
- class \Drupal\Core\Plugin\PluginBase uses \Drupal\Core\StringTranslation\StringTranslationTrait, \Drupal\Core\DependencyInjection\DependencySerializationTrait, \Drupal\Core\Messenger\MessengerTrait extends \Drupal\Component\Plugin\PluginBase
Expanded class hierarchy of TextDefaultFormatter
File
-
core/
modules/ text/ src/ Plugin/ Field/ FieldFormatter/ TextDefaultFormatter.php, line 13
Namespace
Drupal\text\Plugin\Field\FieldFormatterView source
class TextDefaultFormatter extends FormatterBase {
/**
* {@inheritdoc}
*/
public function viewElements(FieldItemListInterface $items, $langcode) {
$elements = [];
// The ProcessedText element already handles cache context & tag bubbling.
// @see \Drupal\filter\Element\ProcessedText::preRenderText()
foreach ($items as $delta => $item) {
$elements[$delta] = [
'#type' => 'processed_text',
'#text' => $item->value,
'#format' => $item->format,
'#langcode' => $item->getLangcode(),
];
}
return $elements;
}
}
Members
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.