Interface Yiisoft\Session\Flash\FlashInterface
| Implemented by | Yiisoft\Session\Flash\Flash |
|---|
Helps working with flash messages, a special type of data, that is available only in the current request and the next request. After that, it will be deleted automatically. Flash messages are particularly useful for displaying confirmation messages.
Public Methods
| Method | Description | Defined By |
|---|---|---|
| add() | Adds a flash message. | Yiisoft\Session\Flash\FlashInterface |
| get() | Returns a flash message. | Yiisoft\Session\Flash\FlashInterface |
| getAll() | Returns all flash messages. | Yiisoft\Session\Flash\FlashInterface |
| has() | Returns a value indicating whether there are flash messages associated with the specified key. | Yiisoft\Session\Flash\FlashInterface |
| remove() | Removes a flash message. | Yiisoft\Session\Flash\FlashInterface |
| removeAll() | Removes all flash messages. | Yiisoft\Session\Flash\FlashInterface |
| set() | Sets a flash message. | Yiisoft\Session\Flash\FlashInterface |
Method Details
Adds a flash message.
If there are existing flash messages with the same key, the new one will be appended to the existing message array.
| public abstract void add ( string $key, mixed $value = true, boolean $removeAfterAccess = true ) | ||
| $key | string |
The key identifying the flash message. |
| $value | mixed |
Flash message. |
| $removeAfterAccess | boolean |
Whether the flash message should be automatically removed only if it is accessed. If false, the flash message will be automatically removed after the next request, regardless if it is accessed or not. If true (default value), the flash message will remain until after it is accessed. |
public function add(string $key, $value = true, bool $removeAfterAccess = true): void;
Returns a flash message.
| public abstract mixed get ( string $key ) | ||
| $key | string |
The key identifying the flash message. |
| return | mixed |
The flash message or an array of messages if {@see \Yiisoft\Session\Flash\add()} was used. |
|---|---|---|
public function get(string $key);
Returns all flash messages.
Flash messages will be automatically deleted in the next request.
| public abstract array getAll ( ) | ||
| return | array |
A set of flash messages. Key => message or key => [message1, message2] if {@see \Yiisoft\Session\Flash\add()} was used. |
|---|---|---|
public function getAll(): array;
Returns a value indicating whether there are flash messages associated with the specified key.
| public abstract boolean has ( string $key ) | ||
| $key | string |
Key identifying the flash message type. |
| return | boolean |
Whether any flash messages exist under specified key. |
|---|---|---|
public function has(string $key): bool;
Removes a flash message.
| public abstract void remove ( string $key ) | ||
| $key | string |
The key identifying the flash message. |
public function remove(string $key): void;
Sets a flash message.
A flash message will be automatically deleted after it is accessed in a request and the deletion will happen in the next request. If there is already an existing flash message with the same key, it will be overwritten by the new one.
| public abstract void set ( string $key, mixed $value = true, boolean $removeAfterAccess = true ) | ||
| $key | string |
The key identifying the flash message. |
| $value | mixed |
Flash message. |
| $removeAfterAccess | boolean |
Whether the flash message should be automatically removed only if it is accessed. If false, the flash message will be automatically removed after the next request, regardless if it is accessed or not. If true (default value), the flash message will remain until after it is accessed. |
public function set(string $key, $value = true, bool $removeAfterAccess = true): void;
Signup or Login in order to comment.