Skip to content

Retrieving messages

Dylan Anderson edited this page Mar 21, 2019 · 8 revisions

Messages of any type can be retrieved by prepending get to the type. For example:

Feedback::getError();
Feedback::getSuccess();
Feedback::getFoo();

To retrieve all messages regardless of type, simply call

Feedback::get();

Retrieving namespaced messages

Namespaced messages can be retrieved by passing the namespace string as the first parameter:

Feedback::getError('user');

Conversely, if you want to retrieve all messages of a type that are not in a given namespace, preface the namespace with "!":

Feedback::getError('!user');
Feedback::getError('!*'); // This will return all error messages without ANY namespace

To retrieve all messages in a namespace, regardless of type, simply call

Feedback::get('.yournamespace');

Further examples

Let's say you've created the following messages:

Feedback::error('Basic error');
Feedback::error('user','User error');
Feedback::success('Basic success');
Feedback::success('user','User success');

Then,

Feedback::getError()

Would return the messages "Basic error","User error"

Feedback::getError('user')

Would return the message "User error"

Feedback::get('.user');

Would return the messages "User error","User success". Note the selector starts with a period - which indicates a namespace. If that period wasn't there, this method call would return all messages of type 'user' (there are none in this example)

Feedback::get('error!*');

Would return the message "Basic error"