NotificationService

This service class contains functions related to the notification functionality.
All public functions are available in the Twig template renderer.

Namespace

IO\Services

Properties
Type Name Description

SessionStorageRepositoryContract

$sessionStorageRepository

Methods
public __construct($sessionStorageRepository)

BasketService constructor.

Parameters

Type

Name

Description

SessionStorageRepositoryContract

$sessionStorageRepository

public getNotifications($clear = true):array

Get a list of all notifications stored in the session

Parameters

Type

Name

Description

bool

$clear

Optional: If true, notifications are cleared from the session afterwards (Default: true)

public log($message, $code, $placeholder = [])

Shorthand for addNotification() with LogLevel::LOG

Parameters

Type

Name

Description

string

$message

The notifications message

int

$code

Optional: Message code (Default: 0)

array

$placeholder

Optional: A placeholder

public info($message, $code, $placeholder = [])

Shorthand for addNotification() with LogLevel::INFO

Parameters

Type

Name

Description

string

$message

The notifications message

int

$code

Optional: Message code (Default: 0)

array

$placeholder

Optional: A placeholder

public warn($message, $code, $placeholder = [])

Shorthand for addNotification() with LogLevel::WARN

Parameters

Type

Name

Description

string

$message

The notifications message

int

$code

Optional: Message code (Default: 0)

array

$placeholder

Optional: A placeholder

public error($message, $code, $placeholder = [])

Shorthand for addNotification() with LogLevel::ERROR

Parameters

Type

Name

Description

string

$message

The notifications message

int

$code

Optional: Message code (Default: 0)

array

$placeholder

Optional: A placeholder

public success($message, $code, $placeholder = [])

Shorthand for addNotification() with LogLevel::SUCCESS

Parameters

Type

Name

Description

string

$message

The notifications message

int

$code

Optional: Message code (Default: 0)

array

$placeholder

Optional: A placeholder

public addNotificationCode($type, $code, $placeholder = [])

Shorthand for addNotification() with empty message and variable type

Parameters

Type

Name

Description

string

$type

The type of notification

int

$code

Optional: Message code (Default: 0)

array

$placeholder

Optional: A placeholder

public hasNotifications():bool

Check if the session currently has any notifications

public clearNotifications()

Clear existing notifications