You are here

public function BlockDescription::build in Display Suite 8.4

Same name and namespace in other branches
  1. 8.2 src/Plugin/DsField/Block/BlockDescription.php \Drupal\ds\Plugin\DsField\Block\BlockDescription::build()
  2. 8.3 src/Plugin/DsField/Block/BlockDescription.php \Drupal\ds\Plugin\DsField\Block\BlockDescription::build()

Renders a field.

Return value

array A renderable array representing the content of the field.

Overrides DsFieldBase::build

File

src/Plugin/DsField/Block/BlockDescription.php, line 24

Class

BlockDescription
Plugin that renders the title of a block.

Namespace

Drupal\ds\Plugin\DsField\Block

Code

public function build() {
  $config = $this
    ->getConfiguration();
  $output = $this
    ->entity()
    ->label();
  if (empty($output)) {
    return [];
  }
  $output = Html::escape($output);

  // Wrapper and class.
  if (!empty($config['wrapper'])) {
    $wrapper = Html::escape($config['wrapper']);
    $class = !empty($config['class']) ? ' class="' . Html::escape($config['class']) . '"' : '';
    $output = '<' . $wrapper . $class . '>' . $output . '</' . $wrapper . '>';
  }
  return [
    '#markup' => $output,
  ];
}