jaeger-app / settings
A settings abstraction.
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 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:
- Configuration Overrides
- Encrypting data on storage
- Convert new line strings into arrays
- Allow for custom values
- Serialize arrays on storage