You are here

trait ElementLinkClassTrait in Element Class Formatter 8

The ElementLinkClassTrait is used to add a class to a field which .

@package Drupal\element_class_formatter\Plugin\Field\FieldFormatter

Hierarchy

File

src/Plugin/Field/FieldFormatter/ElementLinkClassTrait.php, line 13

Namespace

Drupal\element_class_formatter\Plugin\Field\FieldFormatter
View source
trait ElementLinkClassTrait {
  use ElementClassTrait;

  /**
   * {@inheritdoc}
   */
  public static function defaultSettings() {
    return ElementClassTrait::elementClassDefaultSettings(parent::defaultSettings());
  }

  /**
   * {@inheritdoc}
   */
  public function settingsForm(array $form, FormStateInterface $form_state) {
    $elements = parent::settingsForm($form, $form_state);
    $class = $this
      ->getSetting('class');
    return $this
      ->elementClassSettingsForm($elements, $class);
  }

  /**
   * {@inheritdoc}
   */
  public function settingsSummary() {
    $summary = parent::settingsSummary();
    $class = $this
      ->getSetting('class');
    return $this
      ->elementClassSettingsSummary($summary, $class);
  }

  /**
   * {@inheritdoc}
   */
  public function viewElements(FieldItemListInterface $items, $langcode) {
    $elements = parent::viewElements($items, $langcode);
    $class = $this
      ->getSetting('class');
    return $this
      ->setElementClass($elements, $class, $items);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ElementClassTrait::elementClassDefaultSettings public static function Default class value.
ElementClassTrait::elementClassSettingsForm public function Setting form to collect class value.
ElementClassTrait::elementClassSettingsSummary public function Text for settings summary.
ElementClassTrait::setElementClass public function Set the class on the element.
ElementClassTrait::setEntityClass public function Set the class on the entity.
ElementLinkClassTrait::defaultSettings public static function
ElementLinkClassTrait::settingsForm public function
ElementLinkClassTrait::settingsSummary public function
ElementLinkClassTrait::viewElements public function
StringTranslationTrait::$stringTranslation protected property The string translation service. 1
StringTranslationTrait::formatPlural protected function Formats a string containing a count of items.
StringTranslationTrait::getNumberOfPlurals protected function Returns the number of plurals supported by a given language.
StringTranslationTrait::getStringTranslation protected function Gets the string translation service.
StringTranslationTrait::setStringTranslation public function Sets the string translation service to use. 2
StringTranslationTrait::t protected function Translates a string to the current language or to a given language.