e678bfa6017d25a952f48a75a859c0186a25dd9d
[yaffs-website] / layout_test / src / Plugin / Layout / LayoutTestPlugin.php
1 <?php
2
3 namespace Drupal\layout_test\Plugin\Layout;
4
5 use Drupal\Core\Form\FormStateInterface;
6 use Drupal\Core\Layout\LayoutDefault;
7 use Drupal\Core\Plugin\PluginFormInterface;
8
9 /**
10  * The plugin that handles the default layout template.
11  *
12  * @Layout(
13  *   id = "layout_test_plugin",
14  *   label = @Translation("Layout plugin (with settings)"),
15  *   category = @Translation("Layout test"),
16  *   description = @Translation("Test layout"),
17  *   template = "templates/layout-test-plugin",
18  *   regions = {
19  *     "main" = {
20  *       "label" = @Translation("Main Region")
21  *     }
22  *   }
23  * )
24  */
25 class LayoutTestPlugin extends LayoutDefault implements PluginFormInterface {
26
27   /**
28    * {@inheritdoc}
29    */
30   public function defaultConfiguration() {
31     return [
32       'setting_1' => 'Default',
33     ];
34   }
35
36   /**
37    * {@inheritdoc}
38    */
39   public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
40     $form['setting_1'] = [
41       '#type' => 'textfield',
42       '#title' => 'Blah',
43       '#default_value' => $this->configuration['setting_1'],
44     ];
45     return $form;
46   }
47
48   /**
49    * {@inheritdoc}
50    */
51   public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
52   }
53
54   /**
55    * {@inheritdoc}
56    */
57   public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
58     $this->configuration['setting_1'] = $form_state->getValue('setting_1');
59   }
60
61 }