jaeger-app / settings
此软件包已弃用且不再维护。没有建议的替代软件包。
设置抽象。
0.1.2
2016-07-05 12:07 UTC
Requires
- php: >=5.4.0
- jaeger-app/db: ^0.1
- jaeger-app/encrypt: ^0.1
- jaeger-app/exceptions: ^0.1
- jaeger-app/language: ^0.1
Requires (Dev)
- phpunit/phpunit: 4.*
This package is auto-updated.
Last update: 2023-11-18 01:26:16 UTC
README
Jaeger Settings是一个抽象对象,用于管理插件设置的存储。
请注意,您不应实例化此对象;您必须扩展它并在开始之前应用您特定的设置。
安装
将jaeger-app/settings
添加到您的composer.json
文件中作为依赖项
$ composer require jaeger-app/settings
完成此操作后,您必须安装位于data\settings_table.sql的数据库模式。
简单示例
在您的父对象中,确保您扩展了2个属性,$table
和$_defaults
。 $table
应该是您设置表的名称,而$_defaults
是一个键=>值数组,包含您插件设置及其每个设置的默认值。
您还必须定义一个名为validate(array $data, array $extra = array())
的方法,该方法接受设置数据并在失败时返回错误数组。
class MyPluginSettings extends \JaegerApp\Settings { /** * The name of the settings storage table * * @var string */ protected $table = 'my_plugin_settings'; /** * The accepted settings with a default value * * @var array */ protected $_defaults = array( 'key1' => 'value1', 'key2' => 'value2', ); public function __construct($db, $lang) { parent::__construct($db, $lang); $this->setTable($this->table); $this->setTable($this->table); } public function validate(array $data, array $extra = array()) {} }
高级用法
JaegerApp\Settings
包含以下功能
- 配置覆盖
- 在存储中加密数据
- 将换行字符串转换为数组
- 允许自定义值
- 在存储中序列化数组