You are here

Markup.php in Display Suite 8.4

Same filename and directory in other branches
  1. 8.2 src/Plugin/DsField/Markup.php
  2. 8.3 src/Plugin/DsField/Markup.php

File

src/Plugin/DsField/Markup.php
View source
<?php

namespace Drupal\ds\Plugin\DsField;


/**
 * DS field markup base field.
 */
abstract class Markup extends DsFieldBase {

  /**
   * {@inheritdoc}
   */
  public function build() {
    $key = $this
      ->key();
    if (isset($this
      ->entity()->{$key}->value)) {
      $format = $this
        ->format();
      return [
        '#type' => 'processed_text',
        '#text' => $this
          ->entity()->{$key}->value,
        '#format' => $format,
        '#filter_types_to_skip' => [],
        '#langcode' => '',
      ];
    }
    return [];
  }

  /**
   * Gets the key of the field that needs to be rendered.
   */
  protected function key() {
    return '';
  }

  /**
   * Gets the text format.
   */
  protected function format() {
    return 'filtered_html';
  }

}

Classes

Namesort descending Description
Markup DS field markup base field.