Seções

Abstract Class Phalcon\Flash\AbstractFlash

Source on GitHub

Namespace Phalcon\Flash   Uses Phalcon\Di\Di, Phalcon\Di\DiInterface, Phalcon\Di\AbstractInjectionAware, Phalcon\Html\Escaper\EscaperInterface, Phalcon\Session\ManagerInterface, Phalcon\Support\Helper\Str\Interpolate   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");

Class AbstractFlash

@package Phalcon\Flash

Properties

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

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

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

/**
 * @var array
 */
protected cssIconClasses;

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

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

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

/**
 * @var Interpolate
 */
protected interpolator;

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

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

Methods

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

AbstractFlash 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 getAutomaticHtml(): bool;
public function getCssClasses(): array;
public function getCssIconClasses(): 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 ): string | null;

Outputs a message formatting it with HTML

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

Set the autoescape mode in generated HTML

public function setAutomaticHtml( bool $automaticHtml ): AbstractFlash;

Set if the output must be implicitly formatted with HTML

public function setCssClasses( array $cssClasses ): AbstractFlash;

Set an array with CSS classes to format the messages

public function setCssIconClasses( array $cssIconClasses ): AbstractFlash;

Set an array with CSS classes to format the icon messages

public function setCustomTemplate( string $customTemplate ): AbstractFlash;

Set a custom template for showing the messages

public function setEscaperService( EscaperInterface $escaperService ): AbstractFlash;

Sets the Escaper Service

public function setImplicitFlush( bool $implicitFlush ): AbstractFlash;

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

Class Direct

@package Phalcon\Flash

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 \Exception

Exceptions thrown in Phalcon\Flash classes will use this class

Interface Phalcon\Flash\FlashInterface

Source on GitHub

Namespace Phalcon\Flash

Interface FlashInterface

@package Phalcon\Flash

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\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.

Class Session

@package Phalcon\Flash

Constants

const SESSION_KEY = _flashMessages;

Methods

public function clear(): void;

Clear messages in the session messenger

@throws Exception

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

Checks whether there are messages

public function message( string $type, mixed $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, string $type = null ): array;

Returns the messages stored in session

protected function setSessionMessages( array $messages ): array;

Stores the messages in session