jaeger-app/settings

This package is abandoned and no longer maintained. No replacement package was suggested.

A settings abstraction.

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 is an abstract object to manage storage of your plugin settings.

Note that you're NOT meant to instantiate this object; you have to extend it and apply your specific settings before you can get started.

Installation

Add jaeger-app/settings as a requirement to your composer.json:

$ composer require jaeger-app/settings

Once that's done, you'll have to install the database schema located at data\settings_table.sql

Simple Example

In your parent object, ensure you extend have 2 properties, $table and $_defaults. $table should be the name of your settings table, and $_defaults is a key => value array of your plugin's settings and a default value for each.

You'll also have to define a method named validate(array $data, array $extra = array()) that accepts the settings data and returns an array of errors on failure.

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())
    {}
}

Advanced Usage

JaegerApp\Settings includes the following capabilities:

  1. Configuration Overrides
  2. Encrypting data on storage
  3. Convert new line strings into arrays
  4. Allow for custom values
  5. Serialize arrays on storage