Skip to content

Phalcon Flash

Updated View as Markdown

Flash\AbstractFlash

AbstractSource on GitHub

Shows HTML notifications related to different circumstances. Classes can be stylized using CSS

$flash->success("The record was successfully deleted");
$flash->error("Cannot open the file");

Class AbstractFlash

@package Phalcon\Flash

Uses Phalcon\Di\AbstractInjectionAware · Phalcon\Di\Di · Phalcon\Di\DiInterface · Phalcon\Flash\Exceptions\EscaperServiceUnavailable · Phalcon\Flash\Exceptions\FlashMessageNotStringOrArray · Phalcon\Html\Escaper\EscaperInterface · Phalcon\Session\ManagerInterface · Phalcon\Support\Helper\Str\Interpolate

Method Summary

Properties

protectedbool$autoescape = true
protectedbool$automaticHtml = true
protectedarray$cssClasses = []
protectedarray$cssIconClasses = []
protectedstring$customTemplate = ""
protectedEscaperInterface | null$escaperService = null
protectedbool$implicitFlush = true
protectedInterpolate$interpolator
protectedarray$messages = []
protectedSessionInterface|null$sessionService = null

Methods

Public · 20

__construct()

public function __construct(
    EscaperInterface $escaper = null,
    SessionInterface $session = null
);

AbstractFlash constructor.

clear()

public function clear(): void;

Clears accumulated messages when implicit flush is disabled

error()

public function error( string $message ): string|null;

Shows a HTML error message

$flash->error("This is an error");

getAutoescape()

public function getAutoescape(): bool;

getAutomaticHtml()

public function getAutomaticHtml(): bool;

getCssClasses()

public function getCssClasses(): array;

getCssIconClasses()

public function getCssIconClasses(): array;

getCustomTemplate()

public function getCustomTemplate(): string;

getEscaperService()

public function getEscaperService(): EscaperInterface;

Returns the Escaper Service

notice()

public function notice( string $message ): string|null;

Shows a HTML notice/information message

$flash->notice("This is an information");

outputMessage()

public function outputMessage(
    string $type,
    mixed $message
): string|null;

Outputs a message formatting it with HTML

$flash->outputMessage("error", $message);

setAutoescape()

public function setAutoescape( bool $autoescape ): static;

Set the autoescape mode in generated HTML

setAutomaticHtml()

public function setAutomaticHtml( bool $automaticHtml ): static;

Set if the output must be implicitly formatted with HTML

setCssClasses()

public function setCssClasses( array $cssClasses ): static;

Set an array with CSS classes to format the messages

setCssIconClasses()

public function setCssIconClasses( array $cssIconClasses ): static;

Set an array with CSS classes to format the icon messages

setCustomTemplate()

public function setCustomTemplate( string $customTemplate ): static;

Set a custom template for showing the messages

setEscaperService()

public function setEscaperService( EscaperInterface $escaperService ): static;

Sets the Escaper Service

setImplicitFlush()

public function setImplicitFlush( bool $implicitFlush ): static;

Set whether the output must be implicitly flushed to the output or returned as string

success()

public function success( string $message ): string|null;

Shows a HTML success message

$flash->success("The process was finished successfully");

warning()

public function warning( string $message ): string|null;

Shows a HTML warning message

$flash->warning("Hey, this is important");

Flash\Direct

ClassSource on GitHub

Class Direct

@package Phalcon\Flash

Method Summary

Methods

Public · 2

message()

public function message(
    string $type,
    mixed $message
): string|null;

Outputs a message

output()

public function output( bool $remove = true ): void;

Prints the messages accumulated in the flasher

Flash\Exception

ClassSource on GitHub

Exceptions thrown in Phalcon\Flash classes will use this class

Flash\Exceptions\EscaperServiceUnavailable

ClassSource on GitHub

This file is part of the Phalcon Framework.

(c) Phalcon Team <[email protected]>

For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.

Uses Phalcon\Flash\Exception

Method Summary

Methods

Public · 1

__construct()

public function __construct();

Flash\Exceptions\FlashMessageNotStringOrArray

ClassSource on GitHub

This file is part of the Phalcon Framework.

(c) Phalcon Team <[email protected]>

For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.

Uses Phalcon\Flash\Exception

Method Summary

Methods

Public · 1

__construct()

public function __construct();

Flash\Exceptions\SessionServiceUnavailable

ClassSource on GitHub

This file is part of the Phalcon Framework.

(c) Phalcon Team <[email protected]>

For the full copyright and license information, please view the LICENSE.txt file that was distributed with this source code.

Uses Phalcon\Flash\Exception

Method Summary

Methods

Public · 1

__construct()

public function __construct();

Flash\FlashInterface

InterfaceSource on GitHub

Interface FlashInterface

@package Phalcon\Flash

  • Phalcon\Flash\FlashInterface

Method Summary

Methods

Public · 5

error()

public function error( string $message ): string|null;

Shows a HTML error message

message()

public function message(
    string $type,
    string $message
): string|null;

Outputs a message

notice()

public function notice( string $message ): string|null;

Shows a HTML notice/information message

success()

public function success( string $message ): string|null;

Shows a HTML success message

warning()

public function warning( string $message ): string|null;

Shows a HTML warning message

Flash\Session

ClassSource on GitHub

This is an implementation of the Phalcon\Flash\FlashInterface that temporarily stores the messages in session, then messages can be printed in the next request.

Class Session

@package Phalcon\Flash

Uses Phalcon\Flash\Exceptions\SessionServiceUnavailable · Phalcon\Session\ManagerInterface

Method Summary

Constants

stringSESSION_KEY = "_flashMessages"

Methods

Public · 6

clear()

public function clear(): void;

Clear messages in the session messenger

getMessages()

public function getMessages(
    mixed $type = null,
    bool $remove = true
): array;

Returns the messages in the session flasher

getSessionService()

public function getSessionService(): ManagerInterface;

Returns the Session Service

has()

public function has( string $type = null ): bool;

Checks whether there are messages

message()

public function message(
    string $type,
    mixed $message
): string|null;

Adds a message to the session flasher

output()

public function output( bool $remove = true ): void;

Prints the messages in the session flasher

Protected · 2

getSessionMessages()

protected function getSessionMessages(
    bool $remove,
    string $type = null
): array;

Returns the messages stored in session

setSessionMessages()

protected function setSessionMessages( array $messages ): array;

Stores the messages in session

Type to search…

↑↓ navigate↵ selectEsc close