This function checks every message which may exist on every property of
the form (used to tell to JavaScript which messages already exist).

@return array
321837
protected function getFieldsExistingMessages()
    {
        $fieldsMessages = [];
        $formObject = $this->getFormObject();

        if ($formObject->formWasSubmitted()
            && $formObject->hasFormResult()
        ) {
            foreach ($this->getFormObject()->getConfiguration()->getFields() as $field) {
                $fieldsMessages[$field->getName()] = $this->getSingleFieldExistingMessages($field);
            }
        }

        return $fieldsMessages;
    }
14404
protected function attributesThatHaveMessages()
    {
        return collect($this->messages()->toArray())->map(function ($message, $key) {
            return explode('.', $key)[0];
        })->unique()->flip()->all();
    }
768535
protected function _getApplicationMessages()
    {
        $messages       = $this->_application->getMessageQueue();
        $descriptions   = array();

        foreach($messages as $message)
        {
            if($message['type'] == 'error') {
                $descriptions[] = $message['message'];
            }
        }

        return $descriptions;
    }
550526
protected function get_messages() {
        global $SESSION;

        $messages = array();
        if (!empty($SESSION->lesson_messages) && is_array($SESSION->lesson_messages) && array_key_exists($this->properties->id, $SESSION->lesson_messages)) {
            $messages = $SESSION->lesson_messages[$this->properties->id];
            unset($SESSION->lesson_messages[$this->properties->id]);
        }

        return $messages;
    }
610233
public function checkErrors()
    {
        if ($this->model->hasErrors()) {
            $msg = array();
            foreach($this->model->getErrors() as $attribute => $errors) {
               $msg = array_merge($msg, $errors);
            }
            //todo: show several messages. should be checked in x-editable js
            //$this->error(join("\n", $msg));
            $this->error($msg[0]);
        }
    }
292492
public function all()
    {
        return array_merge($this->messages[self::DURABLE], $this->messages[self::NOW]);
    }
124881
public function getAllMessage()
    {
        $messages = [];
        foreach (array_keys($this->errors) as $key) {
            $messages[$key] = $this->getMessage($key);
        }
        return $messages;
    }
65219
public function postbackMessages()
    {
        $result = [];
        foreach ($this->entries as $entry) {
            foreach ($entry->messages as $entryMessage) {
                if ($entryMessage->isPostback) {
                    $result[] = $entryMessage;
                }
            }
        }
        return collect($result);
    }
18560
public function getMessages()
    {
        $messages = parent::getMessages();

        $options = $this->getOptions();
        foreach ($options as $option) {
            $widget = $this->getEntryWidget($option->value);
            $messages = array_merge($messages, $widget->getMessages());
        }

        return $messages;
    }
1242411
public function getValidationMessages()
    {
        $messages = null;
        if (isset($this['validation-messages'])) {
            $message = null;
            foreach ($this['validation-messages'] as $val) {
                $message .= "<li>{$val}</li>\n";
            }
            $messages = "<ul class='validation-message'>\n{$message}</ul>\n";
        }
        return $messages;
    }
284150
public function getMessages()
    {
        $messages = parent::getMessages();

        foreach ($this->children as $child) {
            $messages = array_merge($messages, $child->getMessages());
        }

        return $messages;
    }
35906
protected function getMessages() {
        if (!$this->_messages) {
            $this->_messages = new MessageList(
                $this->version,
                $this->solution['serviceSid'],
                $this->solution['sid']
            );
        }

        return $this->_messages;
    }
722514
public function getValidationErrors()
    {
        if ($this->isValid()) {
            return [];
        }
        
        // if it's already cached, just return it
        if (count($this->validationErrors) > 0) {
            return $this->validationErrors;
        }


        // All errors can be spotted in the fields
        foreach ($this->getFields() as $field) {
            if (!$field->isValid()) {
                $this->validationErrors[$field->getName()] = $field->getErrors(true);
            }
        }

        return $this->validationErrors;
    }
344213
public function messages()
    {
        $messages = [];
        $instances = $this->parents(true);
        foreach ($instances as $instance) {
            $messages[] = $instance->message();
        }
        return $messages;
    }
935160
public function getMessages()
    {
        $messages = array();

        foreach ($this->replicators as $replicator_id) {
            foreach ($this->input_cells as $cell) {
                $messages = array_merge(
                    $messages,
                    $cell->getWidget($replicator_id)->getMessages()
                );
            }
        }

        return $messages;
    }
53029
public function getMessages()
    {
        $messages = $this->fromPrevious;

        foreach ($this->forNow as $key => $values) {
            if (!isset($messages[$key])) {
                $messages[$key] = [];
            }

            foreach ($values as $value) {
                array_push($messages[$key], $value);
            }
        }

        return $messages;
    }
1320296
public function getMessages(): array
    {
        $errors = $this->getErrors();

        $keys = array_keys($errors);

        return array_reduce($keys, function ($messages, $key) use ($errors) {

            $translated = $this->translator->getMessages($key, $errors[$key]);

            return array_merge($messages, $translated);

        }, []);
    }