class NodeTitle in Exclude Node Title 8
Extended NodeTitle Display Suite plugin.
Hierarchy
- class \Drupal\exclude_node_title\Plugin\DsField\Node\NodeTitle extends \Drupal\ds\Plugin\DsField\Node\NodeTitle uses StringTranslationTrait
Expanded class hierarchy of NodeTitle
File
- src/
Plugin/ DsField/ Node/ NodeTitle.php, line 14
Namespace
Drupal\exclude_node_title\Plugin\DsField\NodeView source
class NodeTitle extends DsNodeTitle {
use StringTranslationTrait;
/**
* {@inheritdoc}
*/
public function settingsForm($form, FormStateInterface $form_state) {
$settings = Title::settingsForm($form, $form_state);
$config = $this
->getConfiguration();
$settings['exclude_node_title'] = [
'#type' => 'select',
'#title' => $this
->t('Use Exclude Node Title'),
'#options' => [
'No',
'Yes',
],
'#description' => $this
->t('Use the settings for the Exclude Node Title module for the title. Set to "off" to always show title.'),
'#default_value' => $config['exclude_node_title'],
];
return $settings;
}
/**
* {@inheritdoc}
*/
public function settingsSummary($settings) {
$summary = Title::settingsSummary($settings);
$config = $this
->getConfiguration();
if (!empty($config['exclude_node_title'])) {
$summary[] = $this
->t('Use Exclude Node Title: yes');
}
else {
$summary[] = $this
->t('Use Exclude Node Title: no');
}
return $summary;
}
/**
* {@inheritdoc}
*/
public function defaultConfiguration() {
$configuration = Title::defaultConfiguration();
$configuration['exclude_node_title'] = 1;
return $configuration;
}
/**
* {@inheritdoc}
*/
public function build() {
$config = $this
->getConfiguration();
if ($config['exclude_node_title']) {
$exclude_manager = \Drupal::service('exclude_node_title.manager');
if ($exclude_manager
->isTitleExcluded($this
->entity(), $this
->viewMode())) {
return [
'#markup' => '',
];
}
}
return Field::build();
}
}
Members
Name | Modifiers | Type | Description | Overrides |
---|---|---|---|---|
NodeTitle:: |
public | function | ||
NodeTitle:: |
public | function | ||
NodeTitle:: |
public | function | ||
NodeTitle:: |
public | function | ||
StringTranslationTrait:: |
protected | property | The string translation service. | 1 |
StringTranslationTrait:: |
protected | function | Formats a string containing a count of items. | |
StringTranslationTrait:: |
protected | function | Returns the number of plurals supported by a given language. | |
StringTranslationTrait:: |
protected | function | Gets the string translation service. | |
StringTranslationTrait:: |
public | function | Sets the string translation service to use. | 2 |
StringTranslationTrait:: |
protected | function | Translates a string to the current language or to a given language. |