Fabriq Framework Docs

The Messaging class provides a simple way to capture and display messages on your Fabriq base web applications and websites. The Messaging class is a singleton class that is referenced by calling Messaging::[messaging function]().

Note: the base file in /core/Messaging.class.php should never be edited. To add more functionality to the messaging class, extend the class in a new file (ex: /app/MyMessaging.class.php), include that file in the /app/controllers/application.controller.php file, and reference your custom class in your code (ex: MyMessaging::display_messages('successes');).

Messaging::display_messages($type = 'errors')

Parameters

  • type (optional) default: errors – the type of messages to display

Description

Prints out the messages stored in the given message type. The default styles are defined in the /public/stylesheets/fabriq.base.css stylesheet and can easily be extending in your own stylesheet. The types of messages that the Messaging class manages are errors, messages, successes, and warnings. The function returns true when it has messages to display and false when there are no messages to display as well as no output.

Example(s)

// example displaying errors
Messaging::display_messages();
// example displaying warnings
Messaging::display_messages('warnings');

Added in version: 0.9

Return type: boolean

Messaging::errors()

Description

Returns the errors that are currently being managed by the Messaging class.

Example(s)

// example getting the errors
$myerrors = Messaging::errors();

Added in version: 0.9

Return type: array

Messaging::has_messages($type = 'errors')

Parameters

  • type (optional) default: errors – the type of message to determine if there are any managed by the class

Description

Returns whether or not the Messaging class is managing the given type of messages. The types of messages managed by the Messaging class are errors, messages, successes, and warnings.

Example(s)

// example determining if the Messaging class is managing errors
if (Messaging::has_messages()) {
  // do something here if there are errors
}
// example determining if the Messaging class is managing warnings
if (Messaging::has_messages('warnings')) {
  // do something here if there are warnings
}

Added in version: 0.9

Return type: boolean

Messaging::message($message, $type = 'error')

Parameters

  • message – message to be managed by the Messaging class
  • type (optional) default: error – the type of message being added

Description

This function adds a message to be managed by the Messaging class. The types of message that can be managed are error, message, success, and warning. If the message being passed in empty, the function returns false.

Example(s)

// example adding an error message
Messaging::message('There was an error');
// example adding a success message
Messaging::message('You have succeeded', 'success');

Added in version: 0.9

Return type: boolean

Messaging::messages()

Description

Returns the general messages that are currently being managed by the Messaging class.

Example(s)

// example getting the general messages
$mymessages = Messaging::messages();

Added in version: 0.9

Return type: array

Messaging::successes()

Description

Returns the success messages that are currently being managed by the Messaging class.

Example(s)

// example getting the success messages
$mysuccesses = Messaging::successes();

Added in version: 0.9

Return type: array

Messaging::warnings()

Description

Returns the warning messages that are currently being managed by the Messaging class.

Example(s)

// example getting the warning messages
$mywarnings = Messaging::warnings();

Added in version: 0.9

Return type: array