Updated Drupal to 8.6. This goes with the following updates because it's possible...
[yaffs-website] / web / core / lib / Drupal / Core / Form / FormErrorHandler.php
index 02457ce6d665b4115e80e6977758de9543c625da..695f023a73bb3600315ee1cbcac6daf5757cbc6d 100644 (file)
@@ -3,6 +3,7 @@
 namespace Drupal\Core\Form;
 
 use Drupal\Component\Utility\NestedArray;
+use Drupal\Core\Messenger\MessengerTrait;
 use Drupal\Core\Render\Element;
 
 /**
@@ -10,6 +11,8 @@ use Drupal\Core\Render\Element;
  */
 class FormErrorHandler implements FormErrorHandlerInterface {
 
+  use MessengerTrait;
+
   /**
    * {@inheritdoc}
    */
@@ -39,7 +42,7 @@ class FormErrorHandler implements FormErrorHandlerInterface {
 
     // Loop through all form errors and set an error message.
     foreach ($errors as $error) {
-      $this->drupalSetMessage($error, 'error');
+      $this->messenger()->addMessage($error, 'error');
     }
   }
 
@@ -54,6 +57,7 @@ class FormErrorHandler implements FormErrorHandlerInterface {
    * Grouping example:
    * Assume you have a 'street' element somewhere in a form, which is displayed
    * in a details element 'address'. It might be:
+   *
    * @code
    * $form['street'] = [
    *   '#type' => 'textfield',
@@ -160,13 +164,4 @@ class FormErrorHandler implements FormErrorHandlerInterface {
     $elements['#errors'] = $form_state->getError($elements);
   }
 
-  /**
-   * Wraps drupal_set_message().
-   *
-   * @codeCoverageIgnore
-   */
-  protected function drupalSetMessage($message = NULL, $type = 'status', $repeat = FALSE) {
-    drupal_set_message($message, $type, $repeat);
-  }
-
 }