7e7d1b416267515055100ce6e9667836c8fee1b1
[yaffs-website] / web / modules / contrib / layout_plugin / tests / modules / 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\layout_plugin\Plugin\Layout\LayoutBase;
7
8 /**
9  * The plugin that handles the default layout template.
10  *
11  * @ingroup layout_template_plugins
12  *
13  * @Layout(
14  *   id = "layout_test_plugin",
15  *   label = @Translation("Layout plugin (with settings)"),
16  *   category = @Translation("Layout test"),
17  *   description = @Translation("Test layout"),
18  *   template = "templates/layout-test-plugin",
19  *   regions = {
20  *     "main" = {
21  *       "label" = @Translation("Main Region")
22  *     }
23  *   }
24  * )
25  */
26 class LayoutTestPlugin extends LayoutBase {
27
28   /**
29    * {@inheritdoc}
30    */
31   public function defaultConfiguration() {
32     return parent::defaultConfiguration() + [
33       'setting_1' => 'Default',
34     ];
35   }
36
37   /**
38    * {@inheritdoc}
39    */
40   public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
41     $configuration = $this->getConfiguration();
42     $form['setting_1'] = [
43       '#type' => 'textfield',
44       '#title' => 'Blah',
45       '#default_value' => $configuration['setting_1'],
46     ];
47     return $form;
48   }
49
50   /**
51    * @inheritDoc
52    */
53   public function submitConfigurationForm(array &$form, FormStateInterface $form_state) {
54     parent::submitConfigurationForm($form, $form_state);
55
56     $this->configuration['setting_1'] = $form_state->getValue('setting_1');
57   }
58
59 }