PHP Класс Krucas\Notification\NotificationsBag

Наследование: implements Illuminate\Support\Contracts\ArrayableInterface, implements Illuminate\Support\Contracts\JsonableInterface, implements Countabl\Countable
Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$container string NotificationBag container name.
$defaultFormat string Default format for all message types.
$formats array Default formats for types.
$groupForRender array Sequence of how messages should be rendered by its type.
$matcher array Array of matcher for extracting types.
$notification Krucas\Notification\Notification Notification library instance.
$notifications Krucas\Notification\Collection | null Collection to store all instant notification messages.
$types array Available message types in container.

Открытые методы

Метод Описание
__call ( $name, $arguments ) : NotificationsBag | string Execute short version of function calls.
__construct ( $container, array $types = [], null $defaultFormat = null, array $formats = [] ) Creates new NotificationBag object.
__toString ( ) : string Convert the Bag to its string representation.
add ( $type, string | Krucas\Notification\Message | Closure $message, boolean $flash = true, null $format = null ) : NotificationsBag Adds new notification message to one of collections.
addToGrouping ( $type ) : NotificationsBag Adds type for rendering.
addType ( $type ) : NotificationsBag Add new available type of message to bag.
all ( ) : Krucas\Notification\Collection Returns all messages in bag.
clear ( null $type = null ) : NotificationsBag Clears message for a given type.
clearAll ( ) : NotificationsBag Clears all messages.
clearFormat ( $type ) : NotificationsBag Clear format for a given type.
clearFormats ( ) : NotificationsBag Clear all formats.
clearTypes ( ) : NotificationsBag Resets types values.
count ( ) : integer Count the number of colections.
first ( ) : Krucas\Notification\Message Returns first message object for given type.
get ( $type ) : Krucas\Notification\Collection Returns all messages for given type.
getDefaultFormat ( ) : string Return default format.
getFormat ( $type ) : boolean | string Return format for a given type.
getGroupingForRender ( ) : array Return array with groups list for rendering.
getName ( ) : string Returns assigned container name.
getNotification ( ) : Krucas\Notification\Notification Get notification instance.
getTypes ( ) : array Return available types of messages in container.
group ( ) : NotificationsBag Set order to render types.
has ( $type = null ) : boolean Check if a message is set for given type.
removeFromGrouping ( $type ) : NotificationsBag Removes type from rendering.
setDefaultFormat ( $format ) : NotificationsBag Set default format for all message types.
setFormat ( $type, $format ) : NotificationsBag Set format for a given type.
setFormats ( $formats ) : NotificationsBag Set formats for a given types.
setNotification ( Krucas\Notification\Notification $notification ) : void Set notification instance.
show ( null $type = null, null $format = null ) : string Returns generated output of non flash messages.
showAll ( null $format = null ) : string Renders all messages.
toArray ( ) : array Get the instance as an array.
toJson ( integer $options ) : string Convert the object to its JSON representation.
typeIsAvailable ( $type ) : boolean Determines if type is available in container.
unsetNotification ( ) : void Unset notification instance.

Защищенные методы

Метод Описание
addInstance ( Krucas\Notification\Message $message, string $type, boolean $flash = true, null $format = null ) Add message by instance.
checkFormat ( $format, null $type = null ) : null Returns valid format.
extractType ( $name ) : boolean | array Extract type from a given string.
fireEvent ( $event, $message ) : boolean Fire event for a given message.
getMessagesForRender ( null $type = null ) : Krucas\Notification\Collection Resolves which messages should be returned for rendering.

Описание методов

__call() публичный Метод

Execute short version of function calls.
public __call ( $name, $arguments ) : NotificationsBag | string
$name
$arguments
Результат NotificationsBag | string

__construct() публичный Метод

Creates new NotificationBag object.
public __construct ( $container, array $types = [], null $defaultFormat = null, array $formats = [] )
$container
$types array
$defaultFormat null
$formats array

__toString() публичный Метод

Convert the Bag to its string representation.
public __toString ( ) : string
Результат string

add() публичный Метод

If message is array, adds multiple messages. Message can be string, array (array can contain string for message, or array of message and format). Flashes flashable messages.
public add ( $type, string | Krucas\Notification\Message | Closure $message, boolean $flash = true, null $format = null ) : NotificationsBag
$type
$message string | Krucas\Notification\Message | Closure
$flash boolean
$format null
Результат NotificationsBag

addInstance() защищенный Метод

Add message by instance.
protected addInstance ( Krucas\Notification\Message $message, string $type, boolean $flash = true, null $format = null )
$message Krucas\Notification\Message
$type string
$flash boolean
$format null

addToGrouping() публичный Метод

Adds type for rendering.
public addToGrouping ( $type ) : NotificationsBag
$type
Результат NotificationsBag

addType() публичный Метод

Add new available type of message to bag.
public addType ( $type ) : NotificationsBag
$type
Результат NotificationsBag

all() публичный Метод

Returns all messages in bag.
public all ( ) : Krucas\Notification\Collection
Результат Krucas\Notification\Collection

checkFormat() защищенный Метод

Returns valid format.
protected checkFormat ( $format, null $type = null ) : null
$format
$type null
Результат null

clear() публичный Метод

Clears message for a given type.
public clear ( null $type = null ) : NotificationsBag
$type null
Результат NotificationsBag

clearAll() публичный Метод

Alias for clear(null).
public clearAll ( ) : NotificationsBag
Результат NotificationsBag

clearFormat() публичный Метод

Clear format for a given type.
public clearFormat ( $type ) : NotificationsBag
$type
Результат NotificationsBag

clearFormats() публичный Метод

Clear all formats.
public clearFormats ( ) : NotificationsBag
Результат NotificationsBag

clearTypes() публичный Метод

Resets types values.
public clearTypes ( ) : NotificationsBag
Результат NotificationsBag

count() публичный Метод

Count the number of colections.
public count ( ) : integer
Результат integer

extractType() защищенный Метод

Extract type from a given string.
protected extractType ( $name ) : boolean | array
$name
Результат boolean | array

fireEvent() защищенный Метод

Fire event for a given message.
protected fireEvent ( $event, $message ) : boolean
$event
$message
Результат boolean

first() публичный Метод

Returns first message object for given type.
public first ( ) : Krucas\Notification\Message
Результат Krucas\Notification\Message

get() публичный Метод

Returns all messages for given type.
public get ( $type ) : Krucas\Notification\Collection
$type
Результат Krucas\Notification\Collection

getDefaultFormat() публичный Метод

Return default format.
public getDefaultFormat ( ) : string
Результат string

getFormat() публичный Метод

Return format for a given type.
public getFormat ( $type ) : boolean | string
$type
Результат boolean | string

getGroupingForRender() публичный Метод

Return array with groups list for rendering.
public getGroupingForRender ( ) : array
Результат array

getMessagesForRender() защищенный Метод

Resolves which messages should be returned for rendering.
protected getMessagesForRender ( null $type = null ) : Krucas\Notification\Collection
$type null
Результат Krucas\Notification\Collection

getName() публичный Метод

Returns assigned container name.
public getName ( ) : string
Результат string

getNotification() публичный Метод

Get notification instance.
public getNotification ( ) : Krucas\Notification\Notification
Результат Krucas\Notification\Notification

getTypes() публичный Метод

Return available types of messages in container.
public getTypes ( ) : array
Результат array

group() публичный Метод

Call this method: group('success', 'info', ...)
public group ( ) : NotificationsBag
Результат NotificationsBag

has() публичный Метод

Check if a message is set for given type.
public has ( $type = null ) : boolean
$type
Результат boolean

removeFromGrouping() публичный Метод

Removes type from rendering.
public removeFromGrouping ( $type ) : NotificationsBag
$type
Результат NotificationsBag

setDefaultFormat() публичный Метод

Set default format for all message types.
public setDefaultFormat ( $format ) : NotificationsBag
$format
Результат NotificationsBag

setFormat() публичный Метод

Set format for a given type.
public setFormat ( $type, $format ) : NotificationsBag
$type
$format
Результат NotificationsBag

setFormats() публичный Метод

Set formats for a given types.
public setFormats ( $formats ) : NotificationsBag
$formats
Результат NotificationsBag

setNotification() публичный Метод

Set notification instance.
public setNotification ( Krucas\Notification\Notification $notification ) : void
$notification Krucas\Notification\Notification
Результат void

show() публичный Метод

Returns generated output of non flash messages.
public show ( null $type = null, null $format = null ) : string
$type null
$format null
Результат string

showAll() публичный Метод

Renders all messages.
public showAll ( null $format = null ) : string
$format null
Результат string

toArray() публичный Метод

Get the instance as an array.
public toArray ( ) : array
Результат array

toJson() публичный Метод

Convert the object to its JSON representation.
public toJson ( integer $options ) : string
$options integer
Результат string

typeIsAvailable() публичный Метод

Determines if type is available in container.
public typeIsAvailable ( $type ) : boolean
$type
Результат boolean

unsetNotification() публичный Метод

Unset notification instance.
public unsetNotification ( ) : void
Результат void

Описание свойств

$container защищенное свойство

NotificationBag container name.
protected string $container
Результат string

$defaultFormat защищенное свойство

Default format for all message types.
protected string $defaultFormat
Результат string

$formats защищенное свойство

Default formats for types.
protected array $formats
Результат array

$groupForRender защищенное свойство

Sequence of how messages should be rendered by its type.
protected array $groupForRender
Результат array

$matcher защищенное свойство

Array of matcher for extracting types.
protected array $matcher
Результат array

$notification защищенное свойство

Notification library instance.
protected Notification,Krucas\Notification $notification
Результат Krucas\Notification\Notification

$notifications защищенное свойство

Collection to store all instant notification messages.
protected Collection,Krucas\Notification|null $notifications
Результат Krucas\Notification\Collection | null

$types защищенное свойство

Available message types in container.
protected array $types
Результат array