X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=web%2Fcore%2Flib%2FDrupal%2FCore%2FForm%2FFormErrorHandler.php;h=695f023a73bb3600315ee1cbcac6daf5757cbc6d;hb=refs%2Fheads%2Fd864;hp=02457ce6d665b4115e80e6977758de9543c625da;hpb=af6d1fb995500ae68849458ee10d66abbdcfb252;p=yaffs-website diff --git a/web/core/lib/Drupal/Core/Form/FormErrorHandler.php b/web/core/lib/Drupal/Core/Form/FormErrorHandler.php index 02457ce6d..695f023a7 100644 --- a/web/core/lib/Drupal/Core/Form/FormErrorHandler.php +++ b/web/core/lib/Drupal/Core/Form/FormErrorHandler.php @@ -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); - } - }