Mecha CMS

Deep learning on using the API.

Class Message

Author: Taufik Nurrohman · 108 Views

Tweet

Messages.

Table of Content

Set 

Message::set(...$lot [$kin, $text, $s, $k]);

Example:

Message::set('test', 'This is a test message.');

Note: The engine will first search for a message_{$key}_* language property that has the same suffix as the message text and return that property value:

// Search for `$language->message_test_success`, otherwise return `success`
Message::set('test', 'success');

Get 

Message::get($session_x = true);

Reset 

Message::get($error_x = true);

Send 

Send a HTML email.

Message::send($from, $to, $subject, $message);

Example:

Message::send('from@mail.com', 'to@mail.com', 'Test Subject', '<p>Hello world!</p>');
Message::send('from@mail.com', [
    'a@mail.com',
    'b@mail.com',
    'c@mail.com'
], 'Test Subject', '<p>Hello world!</p>');
Message::send('from@mail.com', [
    'a@mail.com' => 'Person A',
    'b@mail.com' => 'Person B',
    'c@mail.com' => 'Person C'
], 'Test Subject', '<p>Hello world!</p>');

Static Call 

If no kin was defined, this method will function as a shortcut for Message::get().

Message::{$any}($text, $vars = [], $preserve_case = false);

Example:

Message::error('create');
Message::info('create');
Message::success('create');
Message::warning('create');

Message::foo('create');
Message::bar('create');

Note: Calling Message::error() and Message::warning() will increase the internal Message::$x value. This is useful to check for errors before doing something:

if (!Message::$x) {
    File::write('test')->saveTo('success.log');
}

0 Comments

No comments yet.