PHP Class Krucas\Notification\NotificationsBag

Inheritance: implements Illuminate\Support\Contracts\ArrayableInterface, implements Illuminate\Support\Contracts\JsonableInterface, implements Countabl\Countable
Afficher le fichier Open project: edvinaskrucas/notification Class Usage Examples

Protected Properties

Свойство Type Description
$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.

Méthodes publiques

Méthode Description
__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.

Méthodes protégées

Méthode Description
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.

Method Details

__call() public méthode

Execute short version of function calls.
public __call ( $name, $arguments ) : NotificationsBag | string
$name
$arguments
Résultat NotificationsBag | string

__construct() public méthode

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

__toString() public méthode

Convert the Bag to its string representation.
public __toString ( ) : string
Résultat string

add() public méthode

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
Résultat NotificationsBag

addInstance() protected méthode

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() public méthode

Adds type for rendering.
public addToGrouping ( $type ) : NotificationsBag
$type
Résultat NotificationsBag

addType() public méthode

Add new available type of message to bag.
public addType ( $type ) : NotificationsBag
$type
Résultat NotificationsBag

all() public méthode

Returns all messages in bag.
public all ( ) : Krucas\Notification\Collection
Résultat Krucas\Notification\Collection

checkFormat() protected méthode

Returns valid format.
protected checkFormat ( $format, null $type = null ) : null
$format
$type null
Résultat null

clear() public méthode

Clears message for a given type.
public clear ( null $type = null ) : NotificationsBag
$type null
Résultat NotificationsBag

clearAll() public méthode

Alias for clear(null).
public clearAll ( ) : NotificationsBag
Résultat NotificationsBag

clearFormat() public méthode

Clear format for a given type.
public clearFormat ( $type ) : NotificationsBag
$type
Résultat NotificationsBag

clearFormats() public méthode

Clear all formats.
public clearFormats ( ) : NotificationsBag
Résultat NotificationsBag

clearTypes() public méthode

Resets types values.
public clearTypes ( ) : NotificationsBag
Résultat NotificationsBag

count() public méthode

Count the number of colections.
public count ( ) : integer
Résultat integer

extractType() protected méthode

Extract type from a given string.
protected extractType ( $name ) : boolean | array
$name
Résultat boolean | array

fireEvent() protected méthode

Fire event for a given message.
protected fireEvent ( $event, $message ) : boolean
$event
$message
Résultat boolean

first() public méthode

Returns first message object for given type.
public first ( ) : Krucas\Notification\Message
Résultat Krucas\Notification\Message

get() public méthode

Returns all messages for given type.
public get ( $type ) : Krucas\Notification\Collection
$type
Résultat Krucas\Notification\Collection

getDefaultFormat() public méthode

Return default format.
public getDefaultFormat ( ) : string
Résultat string

getFormat() public méthode

Return format for a given type.
public getFormat ( $type ) : boolean | string
$type
Résultat boolean | string

getGroupingForRender() public méthode

Return array with groups list for rendering.
public getGroupingForRender ( ) : array
Résultat array

getMessagesForRender() protected méthode

Resolves which messages should be returned for rendering.
protected getMessagesForRender ( null $type = null ) : Krucas\Notification\Collection
$type null
Résultat Krucas\Notification\Collection

getName() public méthode

Returns assigned container name.
public getName ( ) : string
Résultat string

getNotification() public méthode

Get notification instance.
public getNotification ( ) : Krucas\Notification\Notification
Résultat Krucas\Notification\Notification

getTypes() public méthode

Return available types of messages in container.
public getTypes ( ) : array
Résultat array

group() public méthode

Call this method: group('success', 'info', ...)
public group ( ) : NotificationsBag
Résultat NotificationsBag

has() public méthode

Check if a message is set for given type.
public has ( $type = null ) : boolean
$type
Résultat boolean

removeFromGrouping() public méthode

Removes type from rendering.
public removeFromGrouping ( $type ) : NotificationsBag
$type
Résultat NotificationsBag

setDefaultFormat() public méthode

Set default format for all message types.
public setDefaultFormat ( $format ) : NotificationsBag
$format
Résultat NotificationsBag

setFormat() public méthode

Set format for a given type.
public setFormat ( $type, $format ) : NotificationsBag
$type
$format
Résultat NotificationsBag

setFormats() public méthode

Set formats for a given types.
public setFormats ( $formats ) : NotificationsBag
$formats
Résultat NotificationsBag

setNotification() public méthode

Set notification instance.
public setNotification ( Krucas\Notification\Notification $notification ) : void
$notification Krucas\Notification\Notification
Résultat void

show() public méthode

Returns generated output of non flash messages.
public show ( null $type = null, null $format = null ) : string
$type null
$format null
Résultat string

showAll() public méthode

Renders all messages.
public showAll ( null $format = null ) : string
$format null
Résultat string

toArray() public méthode

Get the instance as an array.
public toArray ( ) : array
Résultat array

toJson() public méthode

Convert the object to its JSON representation.
public toJson ( integer $options ) : string
$options integer
Résultat string

typeIsAvailable() public méthode

Determines if type is available in container.
public typeIsAvailable ( $type ) : boolean
$type
Résultat boolean

unsetNotification() public méthode

Unset notification instance.
public unsetNotification ( ) : void
Résultat void

Property Details

$container protected_oe property

NotificationBag container name.
protected string $container
Résultat string

$defaultFormat protected_oe property

Default format for all message types.
protected string $defaultFormat
Résultat string

$formats protected_oe property

Default formats for types.
protected array $formats
Résultat array

$groupForRender protected_oe property

Sequence of how messages should be rendered by its type.
protected array $groupForRender
Résultat array

$matcher protected_oe property

Array of matcher for extracting types.
protected array $matcher
Résultat array

$notification protected_oe property

Notification library instance.
protected Notification,Krucas\Notification $notification
Résultat Krucas\Notification\Notification

$notifications protected_oe property

Collection to store all instant notification messages.
protected Collection,Krucas\Notification|null $notifications
Résultat Krucas\Notification\Collection | null

$types protected_oe property

Available message types in container.
protected array $types
Résultat array