Phalcon 闪存
Flash\AbstractFlash
GitHub上的源码
-
命名空间
-
使用
Phalcon\Di\AbstractInjectionAware
Phalcon\Di\Di
Phalcon\Di\DiInterface
Phalcon\Html\Escaper\EscaperInterface
Phalcon\Session\ManagerInterface
Phalcon\Support\Helper\Str\Interpolate
-
继承
AbstractInjectionAware
-
实现
显示与不同情况相关的 HTML 通知。类可以使用 CSS 进行样式化
$flash->success("The record was successfully deleted");
$flash->error("Cannot open the file");
类 AbstractFlash
@package Phalcon\Flash
属性
/**
* @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;
方法
public function __construct( EscaperInterface $escaper = null, SessionInterface $session = null );
AbstractFlash 构造函数。 public function clear(): void;
当禁用隐式刷新时清除累积的消息 public function error( string $message ): string | null;
显示 HTML 错误消息 $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;
返回转义服务 public function notice( string $message ): string | null;
显示 HTML 通知/信息消息 $flash->notice("This is an information");
public function outputMessage( string $type, mixed $message ): string | null;
使用 HTML 格式化输出消息 $flash->outputMessage("error", $message);
public function setAutoescape( bool $autoescape ): AbstractFlash;
在生成的 HTML 中设置自动转义模式 public function setAutomaticHtml( bool $automaticHtml ): AbstractFlash;
设置输出是否必须以 HTML 隐式格式化 public function setCssClasses( array $cssClasses ): AbstractFlash;
设置一个包含 CSS 类的数组以格式化消息 public function setCssIconClasses( array $cssIconClasses ): AbstractFlash;
设置一个包含 CSS 类的数组以格式化图标消息 public function setCustomTemplate( string $customTemplate ): AbstractFlash;
设置显示消息的自定义模板 public function setEscaperService( EscaperInterface $escaperService ): AbstractFlash;
设置转义服务 public function setImplicitFlush( bool $implicitFlush ): AbstractFlash;
设置输出是否必须隐式刷新到输出或作为字符串返回 public function success( string $message ): string | null;
显示 HTML 成功消息 $flash->success("The process was finished successfully");
public function warning( string $message ): string | null;
显示 HTML 警告消息 $flash->warning("Hey, this is important");
Flash\Direct
GitHub上的源码
-
命名空间
-
使用
-
继承
AbstractFlash
-
实现
类 Direct
@package Phalcon\Flash
方法
public function message( string $type, mixed $message ): string | null;
输出一条消息 public function output( bool $remove = bool ): void;
打印在闪存中积累的消息 Flash\Exception
GitHub上的源码
在 Phalcon\Flash 类中抛出的异常将使用此类
Flash\FlashInterface
GitHub上的源码
接口 FlashInterface
@package Phalcon\Flash
方法
public function error( string $message ): string | null;
显示 HTML 错误消息 public function message( string $type, string $message ): string | null;
输出一条消息 public function notice( string $message ): string | null;
显示 HTML 通知/信息消息 public function success( string $message ): string | null;
显示 HTML 成功消息 public function warning( string $message ): string | null;
显示 HTML 警告消息 Flash\Session
GitHub上的源码
-
命名空间
-
使用
Phalcon\Session\ManagerInterface
-
继承
AbstractFlash
-
实现
这是 Phalcon\Flash\FlashInterface 的一种实现,它暂时将消息存储在会话中,然后可以在下一个请求中打印这些消息。
类 Session
@package Phalcon\Flash
常量
const SESSION_KEY = _flashMessages;
方法
public function clear(): void;
清除会话信使中的消息 @throws Exception
public function getMessages( mixed $type = null, bool $remove = bool ): array;
返回会话闪存中的消息 public function getSessionService(): ManagerInterface;
返回会话服务 public function has( string $type = null ): bool;
检查是否有消息 public function message( string $type, mixed $message ): string | null;
向会话闪存添加一条消息 public function output( bool $remove = bool ): void;
打印会话闪存中的消息 protected function getSessionMessages( bool $remove, string $type = null ): array;
返回存储在会话中的消息 protected function setSessionMessages( array $messages ): array;
将消息存储在会话中