FormatterTypeBase.php in Custom Formatters 8.3
File
src/FormatterTypeBase.php
View source
<?php
namespace Drupal\custom_formatters;
use Drupal\Core\Form\FormStateInterface;
use Drupal\Core\Plugin\PluginBase;
abstract class FormatterTypeBase extends PluginBase implements FormatterTypeInterface {
protected $entity = NULL;
public function __construct(array $configuration, $plugin_id, $plugin_definition) {
$this->entity = $configuration['entity'];
parent::__construct($configuration, $plugin_id, $plugin_definition);
}
public function calculateDependencies() {
return [];
}
public function settingsForm(array &$form, FormStateInterface $form_state) {
$form['data'] = [
'#title' => $this
->t('Formatter'),
'#type' => 'textarea',
'#default_value' => $this->entity
->get('data'),
'#required' => TRUE,
'#rows' => 10,
];
return $form;
}
public function postLoad() {
}
public function preSave() {
}
public function submitForm(array $form, FormStateInterface $form_state) {
}
}