Flash Messenger - implement session-based messages

 Methods

Add a message with "error" type

addErrorMessage(string $message) : \Zend\Mvc\Controller\Plugin\FlashMessenger

Parameters

$message

string

Returns

Add a message with "info" type

addInfoMessage(string $message) : \Zend\Mvc\Controller\Plugin\FlashMessenger

Parameters

$message

string

Returns

Add a message

addMessage(string $message, null | string $namespace, null | int $hops) : \Zend\Mvc\Controller\Plugin\FlashMessenger

Parameters

$message

string

$namespace

nullstring

$hops

nullint

Returns

\Zend\Mvc\Controller\Plugin\FlashMessengerProvides a fluent interface

Add a message with "success" type

addSuccessMessage(string $message) : \Zend\Mvc\Controller\Plugin\FlashMessenger

Parameters

$message

string

Returns

Add a message with "warning" type

addWarningMessage(string $message) : \Zend\Mvc\Controller\Plugin\FlashMessenger

Parameters

$message

string

Returns

Clear messages from the current request and current namespace

clearCurrentMessages(string $namespace) : bool

Parameters

$namespace

string

Returns

boolTrue if current messages were cleared, false if none existed.

Clear messages from the container

clearCurrentMessagesFromContainer() : bool

Returns

boolTrue if current messages were cleared from the container, false if none existed.

Clear messages from the current namespace

clearCurrentMessagesFromNamespace(string $namespaceToClear) : bool

Parameters

$namespaceToClear

string

Returns

boolTrue if current messages were cleared from the given namespace, false if none existed.

Clear all messages from the previous request & current namespace

clearMessages(string $namespace) : bool

Parameters

$namespace

string

Returns

boolTrue if messages were cleared, false if none existed

Clear all messages from the container

clearMessagesFromContainer() : bool

Returns

boolTrue if messages were cleared, false if none existed

Clear all messages from specific namespace

clearMessagesFromNamespace(string $namespaceToClear) : bool

Parameters

$namespaceToClear

string

Returns

boolTrue if messages were cleared, false if none existed

Complete the countable interface

count() : int

Returns

int

Get session container for flash messages

getContainer() : \Zend\Session\Container

Get the current controller instance

getController() : null | \Zend\Stdlib\DispatchableInterface
Inherited

inherited_from \Zend\Mvc\Controller\Plugin\AbstractPlugin::getController()

Returns

Get messages that have been added to the "error" namespace within this request

getCurrentErrorMessages() : array

Returns

array

Get messages that have been added to the "info" namespace within this request

getCurrentInfoMessages() : array

Returns

array

Get messages that have been added to the current namespace within this request

getCurrentMessages(string $namespace) : array

Parameters

$namespace

string

Returns

array

Get messages that have been added to the current namespace in specific namespace

getCurrentMessagesFromNamespace(string $namespaceToGet) : array

Parameters

$namespaceToGet

string

Returns

array

Get messages that have been added to the "success" namespace within this request

getCurrentSuccessMessages() : array

Returns

array

Get messages that have been added to the "warning" namespace within this request

getCurrentWarningMessages() : array

Returns

array

Get messages from "error" namespace

getErrorMessages() : array

Returns

array

Get messages from "info" namespace

getInfoMessages() : array

Returns

array

Complete the IteratorAggregate interface, for iterating

getIterator() : \ArrayIterator

Returns

Get messages from a specific namespace

getMessages(string $namespace) : array

Parameters

$namespace

string

Returns

array

Get messages from a specific namespace

getMessagesFromNamespace(string $namespaceToGet) : array

Parameters

$namespaceToGet

string

Returns

array

Get the message namespace

getNamespace() : string

Returns

string

Retrieve the session manager

getSessionManager() : \Zend\Session\ManagerInterface

If none composed, lazy-loads a SessionManager instance

Returns

Get messages from "success" namespace

getSuccessMessages() : array

Returns

array

Get messages from "warning" namespace

getWarningMessages() : array

Returns

array

Check to see if messages have been added to "error" namespace within this request

hasCurrentErrorMessages() : bool

Returns

bool

Check to see if messages have been added to "info" namespace within this request

hasCurrentInfoMessages() : bool

Returns

bool

Check to see if messages have been added to the current namespace within this request

hasCurrentMessages(string $namespace) : bool

Parameters

$namespace

string

Returns

bool

Check to see if messages have been added to "success" namespace within this request

hasCurrentSuccessMessages() : bool

Returns

bool

Check to see if messages have been added to "warning" namespace within this request

hasCurrentWarningMessages() : bool

Returns

bool

Whether "error" namespace has messages

hasErrorMessages() : bool

Returns

bool

Whether "info" namespace has messages

hasInfoMessages() : bool

Returns

bool

Whether a specific namespace has messages

hasMessages(string $namespace) : bool

Parameters

$namespace

string

Returns

bool

Whether "success" namespace has messages

hasSuccessMessages() : bool

Returns

bool

Whether "warning" namespace has messages

hasWarningMessages() : bool

Returns

bool

Set the current controller instance

setController(\Zend\Stdlib\DispatchableInterface $controller) : void
Inherited

inherited_from \Zend\Mvc\Controller\Plugin\AbstractPlugin::setController()

Parameters

Change the namespace messages are added to

setNamespace(string $namespace) : \Zend\Mvc\Controller\Plugin\FlashMessenger

Useful for per action controller messaging between requests

Parameters

$namespace

string

Returns

\Zend\Mvc\Controller\Plugin\FlashMessengerProvides a fluent interface

Set the session manager

setSessionManager(\Zend\Session\ManagerInterface $manager) : \Zend\Mvc\Controller\Plugin\FlashMessenger

Pull messages from the session container

getMessagesFromContainer() : void

Iterates through the session container, removing messages into the local scope.

 Properties

 

$container

$container : \Zend\Session\Container

 

$controller

$controller : null | \Zend\Stdlib\DispatchableInterface
Inherited

inherited_from \Zend\Mvc\Controller\Plugin\AbstractPlugin::$$controller
 

Whether a message has been added during this request

$messageAdded : bool

 

Messages from previous request

$messages : array

 

Instance namespace, default is 'default'

$namespace : string

 

$session

$session : \Zend\Session\ManagerInterface

 Constants

 

Default messages namespace

NAMESPACE_DEFAULT 

 

Error messages namespace

NAMESPACE_ERROR 

 

Info messages namespace

NAMESPACE_INFO 

 

Success messages namespace

NAMESPACE_SUCCESS 

 

Warning messages namespace

NAMESPACE_WARNING