class PlainFormatter

Plugin implementation of the 'taxonomy_term_reference_plain' formatter.

Plugin annotation


@FieldFormatter(
  id = "taxonomy_term_reference_plain",
  module = "taxonomy",
  label = @Translation("Plain text"),
  field_types = {
    "taxonomy_term_reference"
  }
)

Hierarchy

Expanded class hierarchy of PlainFormatter

File

drupal/core/modules/taxonomy/lib/Drupal/taxonomy/Plugin/field/formatter/PlainFormatter.php, line 28
Contains \Drupal\taxonomy\Plugin\field\formatter\PlainFormatter.

Namespace

Drupal\taxonomy\Plugin\field\formatter
View source
class PlainFormatter extends TaxonomyFormatterBase {

  /**
   * {@inheritdoc}
   */
  public function viewElements(EntityInterface $entity, $langcode, array $items) {
    $elements = array();
    foreach ($items as $delta => $item) {
      $elements[$delta] = array(
        '#markup' => check_plain($item['entity']
          ->label()),
      );
    }
    return $elements;
  }

}

Members

Namesort descending Modifiers Type Description Overrides
FormatterBase::$field protected property The field definition.
FormatterBase::$instance protected property The field instance definition.
FormatterBase::$label protected property The label display setting.
FormatterBase::$settings protected property The formatter settings. Overrides PluginSettingsBase::$settings
FormatterBase::$viewMode protected property The view mode.
FormatterBase::settingsForm public function Returns a form to configure settings for the formatter. Overrides FormatterInterface::settingsForm 12
FormatterBase::settingsSummary public function Returns a short summary for the current formatter settings. Overrides FormatterInterface::settingsSummary 12
FormatterBase::view public function Builds a renderable array for one field on one entity instance. Overrides FormatterInterface::view
FormatterBase::__construct public function Constructs a FormatterBase object. Overrides PluginBase::__construct
PlainFormatter::viewElements public function Builds a renderable array for a field value. Overrides FormatterInterface::viewElements
PluginBase::$configuration protected property Configuration information passed into the plugin. 1
PluginBase::$pluginDefinition protected property The plugin implementation definition.
PluginBase::$pluginId protected property The plugin_id.
PluginBase::getPluginDefinition public function Returns the definition of the plugin implementation. Overrides PluginInspectionInterface::getPluginDefinition
PluginBase::getPluginId public function Returns the plugin_id of the plugin instance. Overrides PluginInspectionInterface::getPluginId
PluginSettingsBase::$defaultSettingsMerged protected property Whether default settings have been merged into the current $settings.
PluginSettingsBase::getDefaultSettings public function Implements Drupal\field\Plugin\PluginSettingsInterface::getDefaultSettings(). Overrides PluginSettingsInterface::getDefaultSettings
PluginSettingsBase::getSetting public function Implements Drupal\field\Plugin\PluginSettingsInterface::getSetting(). Overrides PluginSettingsInterface::getSetting
PluginSettingsBase::getSettings public function Implements Drupal\field\Plugin\PluginSettingsInterface::getSettings(). Overrides PluginSettingsInterface::getSettings
PluginSettingsBase::mergeDefaults protected function Merges default settings values into $settings.
PluginSettingsBase::setSetting public function Implements Drupal\field\Plugin\PluginSettingsInterface::setSetting(). Overrides PluginSettingsInterface::setSetting
PluginSettingsBase::setSettings public function Implements Drupal\field\Plugin\PluginSettingsInterface::setSettings(). Overrides PluginSettingsInterface::setSettings
TaxonomyFormatterBase::prepareView public function Implements \Drupal\field\Plugin\Type\Formatter\FormatterInterface::prepareView(). Overrides FormatterBase::prepareView