Flash Messenger - implement session-based messages

package Default
inherited_from \Zend\Mvc\Controller\Plugin\AbstractPlugin

 Methods

Add a message with "error" type

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

Parameters

$message

string

Returns

\Zend\Mvc\Controller\Plugin\FlashMessenger

Add a message with "info" type

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

Parameters

$message

string

Returns

\Zend\Mvc\Controller\Plugin\FlashMessenger

Add a message

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

Parameters

$message

string

$namespace

nullstring

$hops

nullinteger

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

\Zend\Mvc\Controller\Plugin\FlashMessenger

Add a message with "warning" type

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

Parameters

$message

string

Returns

\Zend\Mvc\Controller\Plugin\FlashMessenger

Clear messages from the current request and current namespace

clearCurrentMessages(string $namespace = null) : boolean

Parameters

$namespace

string

Returns

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

Clear messages from the container

clearCurrentMessagesFromContainer() : boolean

Returns

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

Clear messages from the current namespace

clearCurrentMessagesFromNamespace(string $namespaceToClear) : boolean

Parameters

$namespaceToClear

string

Returns

booleanTrue 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 = null) : boolean

Parameters

$namespace

string

Returns

booleanTrue if messages were cleared, false if none existed

Clear all messages from the container

clearMessagesFromContainer() : boolean

Returns

booleanTrue if messages were cleared, false if none existed

Clear all messages from specific namespace

clearMessagesFromNamespace(string $namespaceToClear) : boolean

Parameters

$namespaceToClear

string

Returns

booleanTrue if messages were cleared, false if none existed

Complete the countable interface

count() : integer

Returns

integer

Get session container for flash messages

getContainer() : \Zend\Session\Container

Returns

\Zend\Session\Container

Get the current controller instance

getController() : null | \Zend\Stdlib\DispatchableInterface
Inherited
inherited_from \Zend\Mvc\Controller\Plugin\PluginInterface::getController()

Returns

null\Zend\Stdlib\DispatchableInterface

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 = null) : 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

\ArrayIterator

Get messages from a specific namespace

getMessages(string $namespace = null) : 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

\Zend\Session\ManagerInterface

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() : boolean

Returns

boolean

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

hasCurrentInfoMessages() : boolean

Returns

boolean

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

hasCurrentMessages(string $namespace = null) : boolean

Parameters

$namespace

string

Returns

boolean

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

hasCurrentSuccessMessages() : boolean

Returns

boolean

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

hasCurrentWarningMessages() : boolean

Returns

boolean

Whether "error" namespace has messages

hasErrorMessages() : boolean

Returns

boolean

Whether "info" namespace has messages

hasInfoMessages() : boolean

Returns

boolean

Whether a specific namespace has messages

hasMessages(string $namespace = null) : boolean

Parameters

$namespace

string

Returns

boolean

Whether "success" namespace has messages

hasSuccessMessages() : boolean

Returns

boolean

Whether "warning" namespace has messages

hasWarningMessages() : boolean

Returns

boolean

Set the current controller instance

setController(\Zend\Stdlib\DispatchableInterface $controller) : void
Inherited
inherited_from \Zend\Mvc\Controller\Plugin\PluginInterface::setController()

Parameters

$controller

\Zend\Stdlib\DispatchableInterface

Change the namespace messages are added to

setNamespace(string $namespace = 'default') : \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

Parameters

$manager

\Zend\Session\ManagerInterface

Returns

\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

Default

 

$controller

$controller : null | \Zend\Stdlib\DispatchableInterface

Default

 

Whether a message has been added during this request

$messageAdded : boolean

Default

false
 

Messages from previous request

$messages : array

Default

array()
 

Instance namespace, default is 'default'

$namespace : string

Default

self::NAMESPACE_DEFAULT
 

$session

$session : \Zend\Session\ManagerInterface

Default

 Constants

 

Default messages namespace

NAMESPACE_DEFAULT = 'default' 
 

Error messages namespace

NAMESPACE_ERROR = 'error' 
 

Info messages namespace

NAMESPACE_INFO = 'info' 
 

Success messages namespace

NAMESPACE_SUCCESS = 'success' 
 

Warning messages namespace

NAMESPACE_WARNING = 'warning'