LayoutExampleTest.php in Layout Plugin (obsolete, use core's Layout Discovery) 8
File
modules/layout_plugin_example/src/Plugin/Layout/LayoutExampleTest.php
View source
<?php
namespace Drupal\layout_plugin_example\Plugin\Layout;
use Drupal\Core\Form\FormStateInterface;
use Drupal\layout_plugin\Plugin\Layout\LayoutBase;
class LayoutExampleTest extends LayoutBase {
public function defaultConfiguration() {
return parent::defaultConfiguration() + [
'setting_1' => 'Default',
];
}
public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
$configuration = $this
->getConfiguration();
$form['setting_1'] = [
'#type' => 'textfield',
'#title' => 'Blah',
'#default_value' => $configuration['setting_1'],
];
return $form;
}
public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
parent::submitConfigurationForm($form, $form_state);
$this->configuration['setting_1'] = $form_state
->getValue('setting_1');
}
}