getFullMessage() public method

public getFullMessage ( ) : string
return string
Ejemplo n.º 1
0
 /**
  * Formats the messages returned by Respect Validator's NestedValidationException
  *
  * Instead of returning all the messages as a simple array it maps the message to the name of the input field so
  * that way it is easier to parse the messages when they're sent back to the front end.
  *
  * Heavily inspired by NestedValidationException->getAllMessages()
  * @todo make sure $input isn't null
  * @todo handle collision in keys
  * @param NestedValidationException $exceptions
  * @return array
  */
 public function formatMessages(NestedValidationException $exceptions)
 {
     $messages = [$exceptions->getFullMessage()];
     foreach ($exceptions as $exception) {
         $input = $exception->getParams()["input"];
         $message = $exception->getMessage();
         $messages[$input] = $message;
     }
     if (count($messages) > 1) {
         array_shift($messages);
     }
     return $messages;
 }