Documentation

FlashBag extends MessageBag
in package

Simple flash bag

Tags
author

Alexey Bobkov, Samuel Georges

Table of Contents

ERROR  = 'error'
INFO  = 'info'
SESSION_KEY  = '_flash_oc'
SUCCESS  = 'success'
WARNING  = 'warning'
$format  : string
Default format for message output.
$messages  : array<string|int, mixed>
All of the registered messages.
$newMessages  : array<string|int, mixed>
All of the newly registered messages.
$session  : mixed
Session instance.
__construct()  : void
Create a new message bag instance.
__toString()  : string
Convert the message bag to its string representation.
add()  : FlashBag
Add a message to the bag and stores it in the session.
all()  : array<string|int, mixed>
Get first message for every key in the bag.
any()  : bool
Determine if the message bag has any messages.
check()  : bool
Checks to see if any message is available.
count()  : int
Get the number of messages in the container.
error()  : array<string|int, mixed>|FlashBag
Gets / Sets an error message
first()  : string
Get the first message from the bag for a given key.
forget()  : mixed
Removes an object with a specified key or erases the flash data.
get()  : array<string|int, mixed>
Gets all the flash messages of a given type.
getFormat()  : string
Get the default message format.
getMessageBag()  : MessageBag
Get the messages for the instance.
getMessages()  : array<string|int, mixed>
Get the raw messages in the container.
has()  : bool
Determine if messages exist for all of the given keys.
hasAny()  : bool
Determine if messages exist for any of the given keys.
info()  : array<string|int, mixed>|FlashBag
Gets / Sets a information message
isEmpty()  : bool
Determine if the message bag has any messages.
isNotEmpty()  : bool
Determine if the message bag has any messages.
jsonSerialize()  : array<string|int, mixed>
Convert the object into something JSON serializable.
keys()  : array<string|int, mixed>
Get the keys present in the message bag.
merge()  : $this
Merge a new array of messages into the bag.
messages()  : array<string|int, mixed>
Get the raw messages in the container.
purge()  : mixed
setFormat()  : MessageBag
Set the default message format.
store()  : mixed
Stores the flash data to the session.
success()  : array<string|int, mixed>|FlashBag
Sets Gets / a success message
toArray()  : array<string|int, mixed>
Get the instance as an array.
toJson()  : string
Convert the object to its JSON representation.
unique()  : array<string|int, mixed>
Get all of the unique messages for every key in the bag.
warning()  : array<string|int, mixed>|FlashBag
Gets / Sets a warning message
checkFormat()  : string
Get the appropriate format based on the given format.
getMessagesForWildcardKey()  : array<string|int, mixed>
Get the messages for a wildcard key.
isUnique()  : bool
Determine if a key and message combination already exists.
transform()  : array<string|int, mixed>
Format an array of messages.

Constants

SESSION_KEY

public mixed SESSION_KEY = '_flash_oc'

SUCCESS

public mixed SUCCESS = 'success'

WARNING

public mixed WARNING = 'warning'

Properties

$format

Default format for message output.

protected string $format = ':message'

$messages

All of the registered messages.

protected array<string|int, mixed> $messages = []

$newMessages

All of the newly registered messages.

protected array<string|int, mixed> $newMessages = []

$session

Session instance.

protected mixed $session

Methods

__construct()

Create a new message bag instance.

public __construct([array<string|int, mixed> $messages = [] ]) : void
Parameters
$messages : array<string|int, mixed> = []
Return values
void

__toString()

Convert the message bag to its string representation.

public __toString() : string
Return values
string

add()

Add a message to the bag and stores it in the session.

public add(string $key, string $message) : FlashBag
Parameters
$key : string
$message : string
Return values
FlashBag

all()

Get first message for every key in the bag.

public all([string|null $format = null ]) : array<string|int, mixed>
Parameters
$format : string|null = null
Return values
array<string|int, mixed>

any()

Determine if the message bag has any messages.

public any() : bool
Return values
bool

check()

Checks to see if any message is available.

public check() : bool
Return values
bool

count()

Get the number of messages in the container.

public count() : int
Return values
int

error()

Gets / Sets an error message

public error([string|null $message = null ]) : array<string|int, mixed>|FlashBag
Parameters
$message : string|null = null
Return values
array<string|int, mixed>|FlashBag

first()

Get the first message from the bag for a given key.

public first([string $key = null ][, string $format = null ]) : string
Parameters
$key : string = null
$format : string = null
Return values
string

forget()

Removes an object with a specified key or erases the flash data.

public forget([string $key = null ]) : mixed
Parameters
$key : string = null

Specifies a key to remove, optional

Return values
mixed

get()

Gets all the flash messages of a given type.

public get(string $key[, string|null $format = null ]) : array<string|int, mixed>
Parameters
$key : string
$format : string|null = null
Return values
array<string|int, mixed>

getFormat()

Get the default message format.

public getFormat() : string
Return values
string

getMessages()

Get the raw messages in the container.

public getMessages() : array<string|int, mixed>
Return values
array<string|int, mixed>

has()

Determine if messages exist for all of the given keys.

public has(array<string|int, mixed>|string $key) : bool
Parameters
$key : array<string|int, mixed>|string
Return values
bool

hasAny()

Determine if messages exist for any of the given keys.

public hasAny([array<string|int, mixed>|string $keys = [] ]) : bool
Parameters
$keys : array<string|int, mixed>|string = []
Return values
bool

info()

Gets / Sets a information message

public info([string|null $message = null ]) : array<string|int, mixed>|FlashBag
Parameters
$message : string|null = null
Return values
array<string|int, mixed>|FlashBag

isEmpty()

Determine if the message bag has any messages.

public isEmpty() : bool
Return values
bool

isNotEmpty()

Determine if the message bag has any messages.

public isNotEmpty() : bool
Return values
bool

jsonSerialize()

Convert the object into something JSON serializable.

public jsonSerialize() : array<string|int, mixed>
Return values
array<string|int, mixed>

keys()

Get the keys present in the message bag.

public keys() : array<string|int, mixed>
Return values
array<string|int, mixed>

merge()

Merge a new array of messages into the bag.

public merge(MessageProvider|array<string|int, mixed> $messages) : $this
Parameters
$messages : MessageProvider|array<string|int, mixed>
Return values
$this

messages()

Get the raw messages in the container.

public messages() : array<string|int, mixed>
Return values
array<string|int, mixed>

purge()

public purge() : mixed
Return values
mixed

setFormat()

Set the default message format.

public setFormat([string $format = ':message' ]) : MessageBag
Parameters
$format : string = ':message'
Return values
MessageBag

store()

Stores the flash data to the session.

public store() : mixed
Return values
mixed

success()

Sets Gets / a success message

public success([string|null $message = null ]) : array<string|int, mixed>|FlashBag
Parameters
$message : string|null = null
Return values
array<string|int, mixed>|FlashBag

toArray()

Get the instance as an array.

public toArray() : array<string|int, mixed>
Return values
array<string|int, mixed>

toJson()

Convert the object to its JSON representation.

public toJson(int $options) : string
Parameters
$options : int
Return values
string

unique()

Get all of the unique messages for every key in the bag.

public unique([string $format = null ]) : array<string|int, mixed>
Parameters
$format : string = null
Return values
array<string|int, mixed>

warning()

Gets / Sets a warning message

public warning([string|null $message = null ]) : array<string|int, mixed>|FlashBag
Parameters
$message : string|null = null
Return values
array<string|int, mixed>|FlashBag

checkFormat()

Get the appropriate format based on the given format.

protected checkFormat(string $format) : string
Parameters
$format : string
Return values
string

getMessagesForWildcardKey()

Get the messages for a wildcard key.

protected getMessagesForWildcardKey(string $key, string|null $format) : array<string|int, mixed>
Parameters
$key : string
$format : string|null
Return values
array<string|int, mixed>

isUnique()

Determine if a key and message combination already exists.

protected isUnique(string $key, string $message) : bool
Parameters
$key : string
$message : string
Return values
bool

transform()

Format an array of messages.

protected transform(array<string|int, mixed> $messages, string $format, string $messageKey) : array<string|int, mixed>
Parameters
$messages : array<string|int, mixed>
$format : string
$messageKey : string
Return values
array<string|int, mixed>

Search results