Flash\AbstractFlash
AbstractSource on GitHubShows 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");\stdClassPhalcon\Di\AbstractInjectionAwarePhalcon\Flash\AbstractFlash- implementsPhalcon\Flash\FlashInterface
Uses Phalcon\Contracts\Flash\FlashTypes · 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\Traits\Support\Helper\Str\InterpolateTrait
Method Summary
public__construct(EscaperInterface|null $escaper = null,SessionInterface|null $session = null)AbstractFlash constructor.
publicvoidclear()Clears accumulated messages when implicit flush is disabled
publicstring|nullerror(string $message)Shows a HTML error message
publicboolgetAutoescape()Returns the flag that defines whether to automatically escape content or not
publicboolgetAutomaticHtml()Returns the flag that defines whether to automatically use HTML or not
publicarraygetCssClasses()Returns the array of the CSS classes for formatting messages. The key is
publicarraygetCssIconClasses()Returns the array of the icon CSS classes for formatting messages. The
publicstringgetCustomTemplate()Returns the custom template for formatting messages
publicEscaperInterfacegetEscaperService()Returns the Escaper Service
publicstring|nullmessage(string $type,mixed $message)Outputs a message. Delivery semantics differ per implementation:
publicstring|nullnotice(string $message)Shows a HTML notice/information message
publicstring|nulloutputMessage(string $type,mixed $message)Outputs a message formatting it with HTML
publicstaticsetAutoescape(bool $autoescape)Set the autoescape mode in generated HTML
publicstaticsetAutomaticHtml(bool $automaticHtml)Set if the output must be implicitly formatted with HTML
publicstaticsetCssClasses(array $cssClasses)Set an array with CSS classes to format the messages
publicstaticsetCssIconClasses(array $cssIconClasses)Set an array with CSS classes to format the icon messages
publicstaticsetCustomTemplate(string $customTemplate)Set a custom template for showing the messages
publicstaticsetEscaperService(EscaperInterface $escaperService)Sets the Escaper Service
publicstaticsetImplicitFlush(bool $implicitFlush)Set whether the output must be implicitly flushed to the output or
publicstring|nullsuccess(string $message)Shows a HTML success message
publicstring|nullwarning(string $message)Shows a HTML warning message
Properties
protectedbool$autoescape = trueprotectedbool$automaticHtml = trueprotectedarray$cssClasses = []protectedarray$cssIconClasses = []protectedstring$customTemplate = ""protectedEscaperInterface|null$escaperService = nullprotectedbool$implicitFlush = trueprotectedarray$messages = []protectedSessionInterface|null$sessionService = nullMethods
__construct()
public function __construct(
EscaperInterface|null $escaper = null,
SessionInterface|null $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;Returns the flag that defines whether to automatically escape content or not
getAutomaticHtml()
public function getAutomaticHtml(): bool;Returns the flag that defines whether to automatically use HTML or not
getCssClasses()
public function getCssClasses(): array;Returns the array of the CSS classes for formatting messages. The key is the type of message and the value is the CSS class
getCssIconClasses()
public function getCssIconClasses(): array;Returns the array of the icon CSS classes for formatting messages. The key is the type of message and the value is the icon CSS class
getCustomTemplate()
public function getCustomTemplate(): string;Returns the custom template for formatting messages
getEscaperService()
public function getEscaperService(): EscaperInterface;Returns the Escaper Service
message()
abstract public function message(
string $type,
mixed $message
): string|null;Outputs a message. Delivery semantics differ per implementation:
Direct renders and emits immediately, Session stores the raw
message for output on a later request.
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
Note: output() is an echo API and requires implicit flush to remain
enabled (the default). With implicit flush disabled, message() returns
the rendered string while output() does not emit it.
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 GitHubClass Direct
@package Phalcon\Flash
\stdClassPhalcon\Di\AbstractInjectionAwarePhalcon\Flash\AbstractFlashPhalcon\Flash\Direct
Method Summary
publicstring|nullmessage(string $type,mixed $message)Outputs a message
publicvoidoutput(bool $remove = true)Prints the messages accumulated in the flasher
Methods
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 GitHubExceptions thrown in Phalcon\Flash classes will use this class
Flash\Exceptions\EscaperServiceUnavailable
ClassSource on GitHub\ExceptionPhalcon\Flash\ExceptionPhalcon\Flash\Exceptions\EscaperServiceUnavailable
Uses Phalcon\Flash\Exception
Method Summary
Methods
__construct()
public function __construct();Flash\Exceptions\FlashMessageNotStringOrArray
ClassSource on GitHub\ExceptionPhalcon\Flash\ExceptionPhalcon\Flash\Exceptions\FlashMessageNotStringOrArray
Uses Phalcon\Flash\Exception
Method Summary
Methods
__construct()
public function __construct();Flash\Exceptions\SessionServiceUnavailable
ClassSource on GitHub\ExceptionPhalcon\Flash\ExceptionPhalcon\Flash\Exceptions\SessionServiceUnavailable
Uses Phalcon\Flash\Exception
Method Summary
Methods
__construct()
public function __construct();Flash\FlashInterface
InterfaceSource on GitHubInterface FlashInterface
Phalcon\Contracts\Flash\FlashPhalcon\Flash\FlashInterface
Uses Phalcon\Contracts\Flash\Flash
Flash\Session
ClassSource on GitHubThis 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
\stdClassPhalcon\Di\AbstractInjectionAwarePhalcon\Flash\AbstractFlashPhalcon\Flash\Session
Uses Phalcon\Contracts\Flash\FlashTypes · Phalcon\Flash\Exceptions\SessionServiceUnavailable · Phalcon\Html\Escaper\EscaperInterface · Phalcon\Session\ManagerInterface
Method Summary
public__construct(EscaperInterface|null $escaper = null,ManagerInterface|null $session = null,string|null $sessionKey = null)Session constructor.
publicvoidclear()Clear messages in the session messenger
publicarraygetMessages(mixed $type = null,bool $remove = true)Returns the messages in the session flasher
publicManagerInterfacegetSessionService()Returns the Session Service
publicboolhas(string|null $type = null)Checks whether there are messages
publicstring|nullmessage(string $type,mixed $message)Adds a message to the session flasher
publicvoidoutput(bool $remove = true)Prints the messages in the session flasher
protectedarraygetSessionMessages(bool $remove,string|null $type = null)Returns the messages stored in session
protectedarraysetSessionMessages(array $messages)Stores the messages in session
Constants
stringSESSION_KEY = "_flashMessages"Properties
protectedstring$sessionKey = ""Methods
__construct()
public function __construct(
EscaperInterface|null $escaper = null,
ManagerInterface|null $session = null,
string|null $sessionKey = null
);Session constructor.
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|null $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
getSessionMessages()
protected function getSessionMessages(
bool $remove,
string|null $type = null
): array;Returns the messages stored in session
setSessionMessages()
protected function setSessionMessages( array $messages ): array;Stores the messages in session