final class Message implements Stringable (View source)

simple usage examples:


// display simple error message 'Error'
echo Message::error()->getDisplay();

// get simple success message 'Success' $message = Message::success();

// get special notice $message = Message::notice(__('This is a localized notice'));

Methods

__construct(string $string = '', MessageType $type = MessageType::Notice, array $params = [])

No description

string
__toString()

magic method: return string representation for this object

static Message
success(string $string = '', array $params = [])

get Message of type success

static Message
error(string $string = '', array $params = [])

get Message of type error

static Message
notice(string $string, array $params = [])

get Message of type notice

static Message
raw(string $message, MessageType $type = MessageType::Notice)

get Message with customized content

static Message
getMessageForAffectedRows(int $rows)

get Message for type of affected rows

static Message
getMessageForDeletedRows(int $rows)

get Message for type of deleted rows

static Message
getMessageForInsertedRows(int $rows)

get Message for type of inserted rows

static Message
rawError(string $message)

get Message of type error with custom content

static Message
rawNotice(string $message)

get Message of type notice with custom content

static Message
rawSuccess(string $message)

get Message of type success with custom content

bool
isSuccess()

No description

bool
isNotice()

No description

bool
isError()

No description

void
setType(MessageType $type)

No description

void
addParam(Message|string|int|float $param)

add string or Message parameter

void
addParamHtml(string $param)

add parameter as raw HTML, usually in conjunction with strings

void
addMessages(array $messages, string $separator = ' ')

add a bunch of messages at once

void
addMessagesString(array $messages, string $separator = ' ')

add a bunch of messages at once

void
addMessage(Message $message, string $separator = ' ')

add another raw message to be concatenated on displaying

void
addText(string $message, string $separator = ' ')

add another raw message to be concatenated on displaying

void
addHtml(string $message, string $separator = ' ')

add another html message to be concatenated on displaying

string
getMessage()

returns compiled message

string
getMessageWithIcon()

No description

string
getString()

returns Message::$string

string
getContext()

No description

string
getDisplay(Template|null $template = null)

returns HTML code for displaying this message

Details

__construct(string $string = '', MessageType $type = MessageType::Notice, array $params = [])

No description

Parameters

string $string

The message to be displayed

MessageType $type
array $params

Parameters to substitute into the string

string __toString()

magic method: return string representation for this object

Return Value

string

static Message success(string $string = '', array $params = [])

get Message of type success

shorthand for getting a simple success message

Parameters

string $string

A localized string e.g. __('Your SQL query has been executed successfully')

array $params

Parameters to substitute into the string

Return Value

Message

static Message error(string $string = '', array $params = [])

get Message of type error

shorthand for getting a simple error message

Parameters

string $string

A localized string e.g. __('Error')

array $params

Parameters to substitute into the string

Return Value

Message

static Message notice(string $string, array $params = [])

get Message of type notice

shorthand for getting a simple notice message

Parameters

string $string

A localized string e.g. __('The additional features for working with linked tables have been deactivated. To find out why click %shere%s.')

array $params

Parameters to substitute into the string

Return Value

Message

static Message raw(string $message, MessageType $type = MessageType::Notice)

get Message with customized content

shorthand for getting a customized message

Parameters

string $message

A localized string

MessageType $type

Return Value

Message

static Message getMessageForAffectedRows(int $rows)

get Message for type of affected rows

shorthand for getting a customized message

Parameters

int $rows

Number of rows

Return Value

Message

static Message getMessageForDeletedRows(int $rows)

get Message for type of deleted rows

shorthand for getting a customized message

Parameters

int $rows

Number of rows

Return Value

Message

static Message getMessageForInsertedRows(int $rows)

get Message for type of inserted rows

shorthand for getting a customized message

Parameters

int $rows

Number of rows

Return Value

Message

static Message rawError(string $message)

get Message of type error with custom content

shorthand for getting a customized error message

Parameters

string $message

A localized string

Return Value

Message

static Message rawNotice(string $message)

get Message of type notice with custom content

shorthand for getting a customized notice message

Parameters

string $message

A localized string

Return Value

Message

static Message rawSuccess(string $message)

get Message of type success with custom content

shorthand for getting a customized success message

Parameters

string $message

A localized string

Return Value

Message

bool isSuccess()

No description

Return Value

bool

bool isNotice()

No description

Return Value

bool

bool isError()

No description

Return Value

bool

void setType(MessageType $type)

No description

Parameters

MessageType $type

Return Value

void

void addParam(Message|string|int|float $param)

add string or Message parameter

usage

$message->addParam('[em]some string[/em]');

Parameters

Message|string|int|float $param

Return Value

void

void addParamHtml(string $param)

add parameter as raw HTML, usually in conjunction with strings

usage

$message->addParamHtml('<img src="img">');

Parameters

string $param

parameter to add

Return Value

void

void addMessages(array $messages, string $separator = ' ')

add a bunch of messages at once

Parameters

array $messages

to be added

string $separator

to use between this and previous string/message

Return Value

void

void addMessagesString(array $messages, string $separator = ' ')

add a bunch of messages at once

Parameters

array $messages

to be added

string $separator

to use between this and previous string/message

Return Value

void

void addMessage(Message $message, string $separator = ' ')

add another raw message to be concatenated on displaying

Parameters

Message $message

to be added

string $separator

to use between this and previous string/message

Return Value

void

void addText(string $message, string $separator = ' ')

add another raw message to be concatenated on displaying

Parameters

string $message

to be added

string $separator

to use between this and previous string/message

Return Value

void

void addHtml(string $message, string $separator = ' ')

add another html message to be concatenated on displaying

Parameters

string $message

to be added

string $separator

to use between this and previous string/message

Return Value

void

string getMessage()

returns compiled message

Return Value

string

complete message

string getMessageWithIcon()

No description

Return Value

string

string getString()

returns Message::$string

Return Value

string Message::$string

string getContext()

No description

Return Value

string

string getDisplay(Template|null $template = null)

returns HTML code for displaying this message

Parameters

Template|null $template

Return Value

string

whole message box