Class: MessageManager

Class for working with messages - errors, warnings etc.

Implements

Authors

Oleg Schildt

Package

Source code

 

Properties
protected

Internal variable for storing the state whether technical details, programmer warnings and debug information are also sent to the client.

protected

Internal variable for storing the messages.

protected

Internal variable for storing the flag that defines whether for each debug output the source file and line number are written from where it is called.

Methods
public

Stores the information message to be reported.

public

Stores the debugging message to be reported.

public

Stores the error to be reported.

public

Stores the error to be reported.

public

Stores the information message to be reported.

public

Stores the programming warning to be reported.

public

Stores the warning to be reported.

public

Clears all stored messages and active elements.

public

Clears the stored information messages.

public

Clears the stored debugging messages.

public

Clears the stored error messages.

public

Clears the stored information messages.

public

Clears the stored programming warning messages.

public

Clears the stored warning messages.

public

Returns the array of information messages if any have been stored.

public

Returns the array of debugging messages if any have been stored.

public

Returns the array of errors if any have been stored.

public

Returns the array of information messages if any have been stored.

protected

This auxiliary function returns the messages of the desired type.

public

Returns the array of programming warnings if any have been stored.

public

Returns the array of warnings if any have been stored.

public

Checks whether an information message exist.

public

Checks whether a stored debugging message exist.

public

Checks whether a stored error message exist.

public

Checks whether an information message exist.

public

Checks whether a stored programming warning exist.

public

Checks whether a stored error warning exist.

public

Initializes the message manager.


Property: MessageManager::$debug_mode

protected bool $debug_mode = false;

Internal variable for storing the state whether technical details, programmer warnings and debug information are also sent to the client.

Type

bool

Authors

Oleg Schildt

Source code


Property: MessageManager::$messages

protected array $messages = [];

Internal variable for storing the messages.

Type

array

Authors

Oleg Schildt

Source code


Property: MessageManager::$write_source_file_and_line_by_debug

protected bool $write_source_file_and_line_by_debug = false;

Internal variable for storing the flag that defines whether for each debug output the source file and line number are written from where it is called.

Type

bool

Authors

Oleg Schildt

Source code


Method: MessageManager::addBubbleMessage()

public function addBubbleMessage(string $message, array $details = [], bool $autoclose = true): void;

Stores the information message to be reported.

Parameters

Name Pass type Value type Default value Description
$message by value string

The information message to be reported.

$details by value array []

The details might be useful if the message translations are provided on the client, not on the server, and the message should contain some details that may vary from case to case. In that case, the servers return the message id instead of final text and the details, the client uses the message id, gets the final translated text and substitutes the parameters through the details.

$autoclose by value bool true

The flag that controls whether the message box should be closed automatically after a time.

Returns

void

Overrides

Authors

Oleg Schildt

Source code

See also


Method: MessageManager::addDebugMessage()

public function addDebugMessage(string $message, string $file = "", string $line = ""): void;

Stores the debugging message to be reported.

Details

Displaying of the debugging messages might be implemented to simplify the debugging process, e.g. to the browser console or in a lightbox.

Parameters

Name Pass type Value type Default value Description
$message by value string

The debugging message to be reported.

$file by value string ""

The source file where the debug output occurred. Per default, the file where the debug output called.

$line by value string ""

The source file line where the debug output occurred. Per default, the file line where the debug output called.

Returns

void

Overrides

Authors

Oleg Schildt

Source code

See also


Method: MessageManager::addError()

public function addError(string $message, array $details = [], string $related_element = "", string $code = "", string $technical_info = "", string $file = "", string $line = "" ) : void;

Stores the error to be reported.

Parameters

Name Pass type Value type Default value Description
$message by value string

The error message to be reported.

$details by value array []

The details might be useful if the message translations are provided on the client, not on the server, and the message should contain some details that may vary from case to case. In that case, the servers return the message id instead of final text and the details, the client uses the message id, gets the final translated text and substitutes the parameters through the details.

$related_element by value string ""

The error element associated with the error.

$code by value string ""

The error code to be reported.

$technical_info by value string ""

The technical information for the error. Displaying of this part might be controlled over an option "debug_mode".

$file by value string ""

The source file where the error occurred. Per default, the file where the adding error called.

$line by value string ""

The source file line where the error occurred. Per default, the file line where the adding error called.

Returns

void

Overrides

Authors

Oleg Schildt

Source code

See also


Method: MessageManager::addErrorFromSmartException()

public function addErrorFromSmartException(\SmartFactory\SmartException|\SmartFactory\SmartExceptionCollection $smart_exception ) : void;

Stores the error to be reported.

Parameters

Name Pass type Value type Default value Description
$smart_exception by value \SmartFactory\SmartException|\SmartFactory\SmartExceptionCollection

The exception object of collection of exceptions.

Returns

void

Overrides

Authors

Oleg Schildt

Source code

See also


Method: MessageManager::addInfoMessage()

public function addInfoMessage(string $message, array $details = [], bool $autoclose = false): void;

Stores the information message to be reported.

Parameters

Name Pass type Value type Default value Description
$message by value string

The information message to be reported.

$details by value array []

The details might be useful if the message translations are provided on the client, not on the server, and the message should contain some details that may vary from case to case. In that case, the servers return the message id instead of final text and the details, the client uses the message id, gets the final translated text and substitutes the parameters through the details.

$autoclose by value bool false

The flag that controls whether the message box should be closed automatically after a time.

Returns

void

Overrides

Authors

Oleg Schildt

Source code

See also


Method: MessageManager::addProgWarning()

public function addProgWarning(string $message, string $file = "", string $line = ""): void;

Stores the programming warning to be reported.

Details

Programming warnings are shown only if the option "show programming warning" is active.

Parameters

Name Pass type Value type Default value Description
$message by value string

The programming warning message to be reported.

$file by value string ""

The source file where the error occurred. Per default, the file where the adding error called.

$line by value string ""

The source file line where the error occurred. Per default, the file line where the adding error called.

Returns

void

Overrides

Authors

Oleg Schildt

Source code

See also


Method: MessageManager::addWarning()

public function addWarning(string $message, array $details = [], string $related_element = ""): void;

Stores the warning to be reported.

Parameters

Name Pass type Value type Default value Description
$message by value string

The warning message to be reported.

$details by value array []

The details might be useful if the message translations are provided on the client, not on the server, and the message should contain some details that may vary from case to case. In that case, the servers return the message id instead of final text and the details, the client uses the message id, gets the final translated text and substitutes the parameters through the details.

$related_element by value string ""

The error element associated with the warning.

Returns

void

Overrides

Authors

Oleg Schildt

Source code

See also


Method: MessageManager::clearAll()

public function clearAll(): void;

Clears all stored messages and active elements.

Returns

void

Overrides

Authors

Oleg Schildt

Source code

See also


Method: MessageManager::clearBubbleMessages()

public function clearBubbleMessages(): void;

Clears the stored information messages.

Returns

void

Overrides

Authors

Oleg Schildt

Source code

See also


Method: MessageManager::clearDebugMessages()

public function clearDebugMessages(): void;

Clears the stored debugging messages.

Returns

void

Overrides

Authors

Oleg Schildt

Source code

See also


Method: MessageManager::clearErrors()

public function clearErrors(): void;

Clears the stored error messages.

Returns

void

Overrides

Authors

Oleg Schildt

Source code

See also


Method: MessageManager::clearInfoMessages()

public function clearInfoMessages(): void;

Clears the stored information messages.

Returns

void

Overrides

Authors

Oleg Schildt

Source code

See also


Method: MessageManager::clearProgWarnings()

public function clearProgWarnings(): void;

Clears the stored programming warning messages.

Returns

void

Overrides

Authors

Oleg Schildt

Source code

See also


Method: MessageManager::clearWarnings()

public function clearWarnings(): void;

Clears the stored warning messages.

Returns

void

Overrides

Authors

Oleg Schildt

Source code

See also


Method: MessageManager::getBubbleMessages()

public function getBubbleMessages(): array;

Returns the array of information messages if any have been stored.

Details

When the messages are requested, it is assumed they will be displayed. Thus, the message array is cleared to avoid displaying of the same messages twice.

Returns

array

Returns the array of information messages if any have been stored.

Overrides

Authors

Oleg Schildt

Source code

See also


Method: MessageManager::getDebugMessages()

public function getDebugMessages(): array;

Returns the array of debugging messages if any have been stored.

Details

When the messages are requested, it is assumed they will be displayed. Thus, the message array is cleared to avoid displaying of the same messages twice.

Returns

array

Returns the array of debugging messages if any have been stored.

Overrides

Authors

Oleg Schildt

Source code

See also


Method: MessageManager::getErrors()

public function getErrors(): array;

Returns the array of errors if any have been stored.

Details

When the messages are requested, it is assumed they will be displayed. Thus, the message array is cleared to avoid displaying of the same messages twice.

Returns

array

Returns the array of errors if any have been stored.

Overrides

Authors

Oleg Schildt

Source code

See also


Method: MessageManager::getInfoMessages()

public function getInfoMessages(): array;

Returns the array of information messages if any have been stored.

Details

When the messages are requested, it is assumed they will be displayed. Thus, the message array is cleared to avoid displaying of the same messages twice.

Returns

array

Returns the array of information messages if any have been stored.

Overrides

Authors

Oleg Schildt

Source code

See also


Method: MessageManager::getMessages()

protected function getMessages(array $messages): array;

This auxiliary function returns the messages of the desired type.

Parameters

Name Pass type Value type Default value Description
$messages by value array

The messages to be retrieved.

Returns

array

Returns the array of messages.

Authors

Oleg Schildt

Source code


Method: MessageManager::getProgWarnings()

public function getProgWarnings(): array;

Returns the array of programming warnings if any have been stored.

Details

When the messages are requested, it is assumed they will be displayed. Thus, the message array is cleared to avoid displaying of the same messages twice.

Returns

array

Returns the array of programming warnings if any have been stored.

Overrides

Authors

Oleg Schildt

Source code

See also


Method: MessageManager::getWarnings()

public function getWarnings(): array;

Returns the array of warnings if any have been stored.

Details

When the messages are requested, it is assumed they will be displayed. Thus, the message array is cleared to avoid displaying of the same messages twice.

Returns

array

Returns the array of warnings if any have been stored.

Overrides

Authors

Oleg Schildt

Source code

See also


Method: MessageManager::hasBubbleMessages()

public function hasBubbleMessages(): bool;

Checks whether an information message exist.

Returns

bool

Returns true if the information message exists, otherwise false.

Overrides

Authors

Oleg Schildt

Source code

See also


Method: MessageManager::hasDebugMessages()

public function hasDebugMessages(): bool;

Checks whether a stored debugging message exist.

Returns

bool

Returns true if the stored debugging message exists, otherwise false.

Overrides

Authors

Oleg Schildt

Source code

See also


Method: MessageManager::hasErrors()

public function hasErrors(): bool;

Checks whether a stored error message exist.

Returns

bool

Returns true if the stored error message exists, otherwise false.

Overrides

Authors

Oleg Schildt

Source code

See also


Method: MessageManager::hasInfoMessages()

public function hasInfoMessages(): bool;

Checks whether an information message exist.

Returns

bool

Returns true if the information message exists, otherwise false.

Overrides

Authors

Oleg Schildt

Source code

See also


Method: MessageManager::hasProgWarnings()

public function hasProgWarnings(): bool;

Checks whether a stored programming warning exist.

Returns

bool

Returns true if the stored programming warning message exists, otherwise false.

Overrides

Authors

Oleg Schildt

Source code

See also


Method: MessageManager::hasWarnings()

public function hasWarnings(): bool;

Checks whether a stored error warning exist.

Returns

bool

Returns true if the stored warning message exists, otherwise false.

Overrides

Authors

Oleg Schildt

Source code

See also


Method: MessageManager::init()

public function init(array $parameters): void;

Initializes the message manager.

Parameters

Name Pass type Value type Default value Description
$parameters by value array

Settings for message management as an associative array in the form key => value:

  • $parameters["debug_mode"] - if set to True, the technical details, programmer warnings and debug information are also sent to the client. Use it only during debugging!

  • $parameters["write_source_file_and_line_by_debug"] - the flag that defines whether for each debug output the source file and line number are written from where it is called.

Returns

void

Throws

\Exception

It might throw an exception in the case of any errors.

Overrides

Authors

Oleg Schildt

Source code