Jet\UI_messages

In this case it is not a UI element, but a small subsystem for creating user messages. So, for example, information about the fact that an action was successful, or on the contrary about errors and problems.

The subsystem operates in two modes:

  • Messages in session
    This is the so-called message setting. The messages element is created, but placed in the session. From the session, such messages are then read and displayed at the earliest possible opportunity (usually the next page load and view after redirection).
  • Messages for immediate use
    In this mode, messages are created but not saved to the session. They are assumed to be used (i.e., displayed) immediately. The message is actually a regular UI element in this case.

Classes of messages

For the graphical differentiation of the message form (the information about the successful operation will definitely have a different form than the error message) the following constants are predefined. Again, you can define your own message classes if necessary.

Constanta Value
UI_messages::C_SUCCESSsuccess
UI_messages::C_INFOinfo
UI_messages::C_WARNINGwarning
UI_messages::C_DANGERdanger

Kontext zpráv

V režimu nastavení zpráv je možné používat kontext zprávy. Kontext je libovolný textový řetězec, který lze ke zprávě přiřadit a následně podle něj ze session získat zprávy, které do daného kontextu patří.

Overview of methods

Method Meaning of
public static set(
string $class,
string $message,
string $context=''
) : void
Creates and sets the message to session.

Parameters:
  • $class
    Message class - resolution of its form
  • $message
    Text of message
  • $context
    Message context (optional)
public static get(
string|null $context=null
) : UI_messages_message[]
It gets the set messages from the session. Either all messages if $context=null, or only messages with a certain context.
public static create(
string $class,
string $message,
string $context=''
) : UI_messages_message
Creates a message for immediate use.

Parameters:
  • $class
    Message class - resolution of its form
  • $message
    Text of message
  • $context
    Message context (optional)
public static success(
string $message,
string $context=''
) : void
Abbreviated notation of the message creation call.
Sets the message of class UI_messages::C_SUCCESS
public static createSuccess(
string $message
) : UI_messages_message
Abbreviated notation of the message creation call.
Creates the message of class UI_messages::C_SUCCESS
public static info(
string $message,
string $context=''
) : void
Abbreviated notation of the message creation call.
Sets the message of class UI_messages::C_INFO
public static createInfo(
string $message
) : UI_messages_message
Abbreviated notation of the message creation call.
Creates the message of class UI_messages::C_INFO
public static warning(
string $message,
string $context=''
)
Abbreviated notation of the message creation call.
Sets the message of class UI_messages::C_WARNING
public static createWarning(
string $message
) : UI_messages_message
Abbreviated notation of the message creation call.
Creates the message of class UI_messages::C_WARNING
public static danger(
string $message,
string $context=''
)
Abbreviated notation of the message creation call.
Sets the message of class UI_messages::C_DANGER
public static createDanger(
string $message
) : UI_messages_message
Abbreviated notation of the message creation call.
Creates the message of class UI_messages::C_DANGER
Previous chapter
Jet\UI_dataGrid_footer
Next chapter
Jet\UI_messages_message