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=9783cb5c4a6fe31cc5554aab689ca77cf81019e8;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/web/core/lib/Drupal/Core/Form/FormErrorHandler.php b/web/core/lib/Drupal/Core/Form/FormErrorHandler.php index 9783cb5c4..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', @@ -127,7 +131,7 @@ class FormErrorHandler implements FormErrorHandlerInterface { } // Additionally store the errors of the direct child itself, keyed by - // it's parent elements structure. + // its parent elements structure. if (!empty($child['#errors'])) { $child_parents = implode('][', $child['#array_parents']); $children_errors[$child_parents] = $child['#errors']; @@ -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); - } - }