jaeger-app/settings

此软件包已弃用且不再维护。没有建议的替代软件包。

设置抽象。

0.1.2 2016-07-05 12:07 UTC

This package is auto-updated.

Last update: 2023-11-18 01:26:16 UTC


README

Build Status Scrutinizer Code Quality Author GitHub license

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包含以下功能

  1. 配置覆盖
  2. 在存储中加密数据
  3. 将换行字符串转换为数组
  4. 允许自定义值
  5. 在存储中序列化数组