Sections

Abstract Class Phalcon\Flash\AbstractFlash

Source on GitHub

Namespace Phalcon\Flash   Uses Phalcon\Di, Phalcon\DiInterface, Phalcon\Di\InjectionAwareInterface, Phalcon\Escaper\EscaperInterface, Phalcon\Flash\Exception   Implements FlashInterface, InjectionAwareInterface

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 = ;

//
protected container;

//
protected escaperService;

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

//
protected messages;

Metody

public function __construct( mixed $cssClasses = null ): void;

Phalcon\Flash constructor

public function clear(): void;

Clears accumulated messages when implicit flush is disabled

public function error( string $message ): string;

Shows a HTML error message

$flash->error("This is an error");
public function getAutoescape(): bool;

Returns the autoescape mode in generated html

public function getCustomTemplate(): string;

Returns the custom template set

public function getDI(): DiInterface;

Returns the internal dependency injector

public function getEscaperService(): EscaperInterface;

Returns the Escaper Service

public function notice( string $message ): string;

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);
@param string array message @return string void
public function setAutoescape( bool $autoescape ): Flash;

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 setDI( DiInterface $container ): FlashInterface;

Sets the dependency injector

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;

Shows a HTML success message

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

Shows a HTML warning message

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

Class Phalcon\Flash\Direct

Source on GitHub

Namespace Phalcon\Flash   Uses Phalcon\Flash\AbstractFlash   Extends AbstractFlash

This is a variant of the Phalcon\Flash that immediately outputs any message passed to it

Metody

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

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 will use this class

Interface Phalcon\Flash\FlashInterface

Source on GitHub

Namespace Phalcon\Flash

Phalcon\FlashInterface

Interface for Phalcon\Flash

Metody

public function error( string $message ): string;

Shows a HTML error message

public function message( string $type, string $message );

Outputs a message

public function notice( string $message ): string;

Shows a HTML notice/information message

public function success( string $message ): string;

Shows a HTML success message

public function warning( string $message ): string;

Shows a HTML warning message

Class Phalcon\Flash\Session

Source on GitHub

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

Temporarily stores the messages in session, then messages can be printed in the next request

Metody

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 has( mixed $type = null ): bool;

Checks whether there are messages

public function message( string $type, string $message ): void;

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