cakedone/cakephp-api-flash

CakePHP 3 插件,用于将任何闪存消息添加到响应中。

安装: 0

依赖项: 0

建议者: 0

安全: 0

星标: 0

关注者: 2

分支: 0

开放问题: 0

类型:cakephp-plugin

dev-master 2015-10-16 22:37 UTC

This package is not auto-updated.

Last update: 2024-09-28 18:28:24 UTC


README

此插件仅包含一个组件,用于在控制器中设置序列化响应中的闪存消息。

用法

在所需控制器中加载组件

# the initialize method

$this->loadComponent('ApiFlash');

然后只需从任何控制器方法调用 ApiFlashComponent#set(key, message) 方法

$this->ApiFlash->set('success', 'You were successfully authenticated!')

它将简单地将一个数组添加到响应体的 flash 键中

[
	'flash' => [
		'success' => 'You were successfully authenticated!'
	]
]

配置

您可以在响应中设置数组的键。只需将 key 索引添加到 loadComponent 调用的配置中即可。

# the intialize method

$this->loadComponent('ApiFlash', ['key' => 'feedback']);