Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / settings_tray / tests / modules / settings_tray_test / src / Plugin / Block / ValidationErrorBlock.php
diff --git a/web/core/modules/settings_tray/tests/modules/settings_tray_test/src/Plugin/Block/ValidationErrorBlock.php b/web/core/modules/settings_tray/tests/modules/settings_tray_test/src/Plugin/Block/ValidationErrorBlock.php
new file mode 100644 (file)
index 0000000..f54b1a3
--- /dev/null
@@ -0,0 +1,33 @@
+<?php
+
+namespace Drupal\settings_tray_test\Plugin\Block;
+
+use Drupal\Core\Block\BlockBase;
+use Drupal\Core\Form\FormStateInterface;
+
+/**
+ * Provides a 'Block with validation error' test block.
+ *
+ * @Block(
+ *   id = "settings_tray_test_validation",
+ *   admin_label = @Translation("Block with validation error")
+ * )
+ */
+class ValidationErrorBlock extends BlockBase {
+
+  /**
+   * {@inheritdoc}
+   */
+  public function build() {
+    return ['#markup' => '<span>If I had more time this would be very witty :(.</span>'];
+  }
+
+  /**
+   * {@inheritdoc}
+   */
+  public function validateConfigurationForm(array &$form, FormStateInterface $form_state) {
+    parent::validateConfigurationForm($form, $form_state);
+    $form_state->setError($form['label'], 'Sorry system error. Please save again.');
+  }
+
+}