Sections

Abstract Class Phalcon\Flash\AbstractFlash

Source on GitHub

Namespace Phalcon\Flash
Uses Phalcon\Di, Phalcon\Di\DiInterface, Phalcon\Di\AbstractInjectionAware, Phalcon\Escaper\EscaperInterface, Phalcon\Session\ManagerInterface
Extends AbstractInjectionAware
Implements FlashInterface

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");

Properties

/**
 * @var bool
 */
protected autoescape = true;

/**
 * @var bool
 */
protected automaticHtml = true;

/**
 * @var array
 */
protected cssClasses;

/**
 * @var string
 */
protected customTemplate = ;

/**
 * @var EscaperInterface | null
 */
protected escaperService;

/**
 * @var bool
 */
protected implicitFlush = true;

/**
 * @var array
 */
protected messages;

/**
 * @var SessionInterface | null
 */
protected sessionService;

Methods

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

Phalcon\Flash constructor

public function clear(): void;

Clears accumulated messages when implicit flush is disabled

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

Shows a HTML error message

$flash->error("This is an error");
public function getAutoescape(): bool
public function getCssClasses(): array
public function getCustomTemplate(): string
public function getEscaperService(): EscaperInterface;

Returns the Escaper Service

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

Shows a HTML notice/information message

$flash->notice("This is an information");
public function outputMessage( string $type, mixed $message );

Outputs a message formatting it with HTML

$flash->outputMessage("error", $message);
public function setAutoescape( bool $autoescape ): FlashInterface;

Set the autoescape mode in generated HTML

public function setAutomaticHtml( bool $automaticHtml ): FlashInterface;

Set if the output must be implicitly formatted with HTML

public function setCssClasses( array $cssClasses ): FlashInterface;

Set an array with CSS classes to format the messages

public function setCustomTemplate( string $customTemplate ): FlashInterface;

Set an custom template for showing the messages

public function setEscaperService( EscaperInterface $escaperService ): FlashInterface;

Sets the Escaper Service

public function setImplicitFlush( bool $implicitFlush ): FlashInterface;

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

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

Shows a HTML success message

$flash->success("The process was finished successfully");
public function warning( string $message ): string | null;

Shows a HTML warning message

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

Class Phalcon\Flash\Direct

Source on GitHub

Namespace Phalcon\Flash
Extends AbstractFlash

This is an implementation of the Phalcon\Flash\FlashInterface that immediately outputs any message passed to it.

Methods

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

Outputs a message

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

Prints the messages accumulated in the flasher

Class Phalcon\Flash\Exception

Source on GitHub

Namespace Phalcon\Flash
Extends \Phalcon\Exception

Exceptions thrown in Phalcon\Flash classes will use this class

Interface Phalcon\Flash\FlashInterface

Source on GitHub

Namespace Phalcon\Flash

Phalcon\Flash\FlashInterface

Interface for Phalcon\Flash classes

Methods

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

Shows a HTML error message

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

Outputs a message

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

Shows a HTML notice/information message

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

Shows a HTML success message

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

Shows a HTML warning message

Class Phalcon\Flash\Session

Source on GitHub

Namespace Phalcon\Flash
Uses Phalcon\Di\DiInterface, Phalcon\Session\ManagerInterface
Extends AbstractFlash

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.

Methods

public function clear(): void;

Clear messages in the session messenger

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

Returns the messages in the session flasher

public function getSessionService(): ManagerInterface;

Returns the Session Service

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

Checks whether there are messages

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

Adds a message to the session flasher

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

Prints the messages in the session flasher

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

Returns the messages stored in session

protected function setSessionMessages( array $messages ): array;

Stores the messages in session