Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / modules / layout_builder / tests / modules / layout_builder_test / src / Plugin / Block / TestAjaxBlock.php
diff --git a/web/core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Block/TestAjaxBlock.php b/web/core/modules/layout_builder/tests/modules/layout_builder_test/src/Plugin/Block/TestAjaxBlock.php
new file mode 100644 (file)
index 0000000..1f1eeb0
--- /dev/null
@@ -0,0 +1,59 @@
+<?php
+
+namespace Drupal\layout_builder_test\Plugin\Block;
+
+use Drupal\Core\Block\BlockBase;
+use Drupal\Core\Form\FormStateInterface;
+
+/**
+ * Provides a 'TestAjax' block.
+ *
+ * @Block(
+ *   id = "layout_builder_test_testajax",
+ *   admin_label = @Translation("TestAjax"),
+ *   category = @Translation("Test")
+ * )
+ */
+class TestAjaxBlock extends BlockBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function blockForm($form, FormStateInterface $form_state) {
+    $form['ajax_test'] = [
+      '#type' => 'radios',
+      '#options' => [
+        1 => $this->t('Ajax test option 1'),
+        2 => $this->t('Ajax test option 2'),
+      ],
+      '#prefix' => '<div id="test-ajax-wrapper">',
+      '#suffix' => '</div>',
+      '#title' => $this->t('Time in this ajax test is @time', [
+        '@time' => time(),
+      ]),
+      '#ajax' => [
+        'wrapper' => 'test-ajax-wrapper',
+        'callback' => [$this, 'ajaxCallback'],
+      ],
+    ];
+    return $form;
+  }
+
+  /**
+   * Ajax callback.
+   */
+  public function ajaxCallback($form, $form_state) {
+    return $form['settings']['ajax_test'];
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function build() {
+    $build['content'] = [
+      '#markup' => $this->t('Every word is like an unnecessary stain on silence and nothingness.'),
+    ];
+    return $build;
+  }
+
+}