public function getMessages($severity = null)
    {
        if ($severity === null) {
            return $this->messages;
        }

        $messages = [];
        foreach ($this->messages as $message) {
            if ($message->getSeverity() === $severity) {
                $messages[] = $message;
            }
        }
        return $messages;
    }
public function getMessages($severity = null)
    {
        if ($severity === null) {
            return $this->messages;
        }

        $messages = [];
        foreach ($this->messages as $message) {
            if ($message->getSeverity() === $severity) {
                $messages[] = $message;
            }
        }
        return $messages;
    }
public function getMessages ( $ severity = null ) { if ( $ severity === null ) { return $ this -> messages ; } $ messages = [ ] ; foreach ( $ this -> messages as $ message ) { if ( $ message -> getSeverity ( ) === $ severity ) { $ messages [ ] = $ message ; } } return $ messages ; }
Returns all currently stored flash messages.

@param string $severity severity of messages (from Message::SEVERITY_* constants) to return.
@return array<Message>
@api
Returns all currently stored flash messages .