Chyrp

Flash

Stores messages (notice, warning, message) to display to the user after a redirect.

Summary
Flash Stores messages (notice, warning, message) to display to the user after a redirect.
Variables
$notices Manages notices.
$warnings Manages warnings.
$messages Manages messages.
$all Manages all Flashes.
$exists Do any Flashes exist?
Functions
__construct Removes empty notification variables from the session.
prepare Prepare the structure of the “flash” session value.
message Add a message (neutral) to the session.
notice Add a notice (positive) message to the session.
warning Add a warning (negative) message to the session.
messages Sets Flash.$messages to $_SESSION[‘messages’] and destroys the session value.
notices Sets Flash.$notices to $_SESSION[‘notices’] and destroys the session value.
warnings Sets Flash.$warnings to $_SESSION[‘warnings’] and destroys the session value.
all Returns an associative array of all messages and destroys their session values.
serve Serves a message of type $type and destroys it from the session.
exists Checks for flash messages.
current Returns a singleton reference to the current class.

Variables

$notices

private $notices

Manages notices.

$warnings

private $warnings

Manages warnings.

$messages

private $messages

Manages messages.

$all

private $all

Manages all Flashes.

$exists

static $exists

Do any Flashes exist?

Functions

__construct

private function __construct()

Removes empty notification variables from the session.

prepare

static function prepare( $type )

Prepare the structure of the “flash” session value.

message

static function message( $message,   
$redirect_to  =  null )

Add a message (neutral) to the session.

Parameters

$message Message to display.
$redirect_to URL to redirect to after the message is stored.

notice

static function notice( $message,   
$redirect_to  =  null )

Add a notice (positive) message to the session.

Parameters

$message Message to display.
$redirect_to URL to redirect to after the message is stored.

warning

static function warning( $message,   
$redirect_to  =  null )

Add a warning (negative) message to the session.

Parameters

$message Message to display.
$redirect_to URL to redirect to after the message is stored.

messages

public function messages()

Sets Flash.$messages to $_SESSION[‘messages’] and destroys the session value.

Returns

Flash.$messages

notices

public function notices()

Sets Flash.$notices to $_SESSION[‘notices’] and destroys the session value.

Returns

Flash.$notices

warnings

public function warnings()

Sets Flash.$warnings to $_SESSION[‘warnings’] and destroys the session value.

Returns

Flash.$warnings

all

public function all()

Returns an associative array of all messages and destroys their session values.

Returns

Flash.$all

serve

public function serve( $type )

Serves a message of type $type and destroys it from the session.

exists

static function exists( $type  =  null )

Checks for flash messages.

Parameters

$type message, notice, or warning.

current

public static function & current()

Returns a singleton reference to the current class.