Title.php in Display Suite 8.2
File
src/Plugin/DsField/Title.php
View source
<?php
namespace Drupal\ds\Plugin\DsField;
use Drupal\Core\Form\FormStateInterface;
abstract class Title extends Field {
public function settingsForm($form, FormStateInterface $form_state) {
$config = $this
->getConfiguration();
$settings['link'] = array(
'#type' => 'checkbox',
'#title' => 'Link',
'#default_value' => $config['link'],
);
$settings['wrapper'] = array(
'#type' => 'textfield',
'#title' => 'Wrapper',
'#default_value' => $config['wrapper'],
'#description' => $this
->t('Eg: h1, h2, p'),
);
$settings['class'] = array(
'#type' => 'textfield',
'#title' => 'Class',
'#default_value' => $config['class'],
'#description' => $this
->t('Put a class on the wrapper. Eg: block-title'),
);
return $settings;
}
public function settingsSummary($settings) {
$config = $this
->getConfiguration();
$summary = array();
if (!empty($config['link'])) {
$summary[] = 'Link: yes';
}
else {
$summary[] = 'Link: no';
}
$summary[] = 'Wrapper: ' . $config['wrapper'];
if (!empty($config['class'])) {
$summary[] = 'Class: ' . $config['class'];
}
return $summary;
}
public function defaultConfiguration() {
$configuration = array(
'link' => 0,
'wrapper' => 'h2',
'class' => '',
);
return $configuration;
}
protected function entityRenderKey() {
return 'title';
}
}
Classes
Name |
Description |
Title |
Plugin that renders a title. |