You are here

public function NodeTitle::__construct in Display Suite 8.4

Same name and namespace in other branches
  1. 8.2 src/Plugin/DsField/Node/NodeTitle.php \Drupal\ds\Plugin\DsField\Node\NodeTitle::__construct()
  2. 8.3 src/Plugin/DsField/Node/NodeTitle.php \Drupal\ds\Plugin\DsField\Node\NodeTitle::__construct()

Constructs a Display Suite field plugin.

Overrides DsFieldBase::__construct

File

src/Plugin/DsField/Node/NodeTitle.php, line 22

Class

NodeTitle
Plugin that renders the title of a node.

Namespace

Drupal\ds\Plugin\DsField\Node

Code

public function __construct($configuration, $plugin_id, $plugin_definition) {

  // Set the title, used to construct the field label, based on the label
  // of the node type's title field.
  if (!empty($configuration['entity'])) {

    /* @var \Drupal\Core\Field\FieldDefinitionInterface $field */
    $field = $configuration['entity']
      ->getFieldDefinition('title');
    $title = $field
      ->getLabel();
    $configuration['field']['title'] = $title;
    $plugin_definition['title'] = $title;
  }
  parent::__construct($configuration, $plugin_id, $plugin_definition);
}