PHP Класс WPDKConfiguration

## Overview You rarely (never) instantiate WPDKConfiguration object directly. Instead, you instantiate subclasses of the WPDKConfiguration class. ### Getting started Write a your own custom class and extends WPDKConfiguration. For example: class MySettings extends WPDKConfiguration { } Implements your custom properties and your branch to other configuration class MySettings extends WPDKConfiguration { const CONFIGURATION_NAME = 'mysetting-config'; public $version = '1.0'; function __construct() { parent::__construct( self::CONFIGURATION_NAME ); } } You can implement this utility static method to get the configuration from database or create it onfly if missing or the first time. class MySettings extends WPDKConfiguration { const CONFIGURATION_NAME = 'mysetting-config'; public $version = '1.0'; static function init() { return parent::init( self::CONFIGURATION_NAME, __CLASS__ ); } function __construct() { parent::__construct( self::CONFIGURATION_NAME ); } } If you have a sub configuration branch, or subset of configuration, use: class MySettings extends WPDKConfiguration { const CONFIGURATION_NAME = 'mysetting-config'; public $version = '1.0'; My configuration branch public $branch; static function init() { return parent::init( self::CONFIGURATION_NAME, __CLASS__ ); } function __construct() { parent::__construct( self::CONFIGURATION_NAME ); $this->branch = new MyConfigurationBranch(); } } class MyConfigurationBranch { public $number_of_seat; function __construct() { $this->number_of_seat = 10; // Default value } } ### Reset to default values The code above shows how it possible reset all or a portion of your configuration. To reset a branch to default values just: $myconfiguration->branch = new MyConfigurationBranch(); If you like it possible implement a simple resetToDefault() method as: class MyConfigurationBranch { public $number_of_seat; function __construct() { $this->resetToDefault(); } function resetToDefault() { $this->number_of_seat = 10; // Default value } } ### Developing When you are in develop your settings change and the store object on db could be different from last develop version. No problem, you can invoke the delta() method to perform a delta from the database version and the onfly (last) version. This method usually is called on activation of plugin. In this way you can align the configuration setting just deactive and re active your plugin.
Устаревший: since 1.2.0 use WPDKPreferences instead
С версии: 0.6.2
Автор: =undo= ([email protected])
Показать файл Открыть проект Примеры использования класса

Открытые методы

Метод Описание
delete ( ) Delete this configuration
delta ( ) : object Do a delta compare/combine from two tree object config
init ( ) public static function init( $name = null, $class_name = null ) {
update ( ) Update on database this configuration.

Защищенные методы

Метод Описание
__construct ( string $name ) Return an instance of WPDKConfiguration class

Описание методов

__construct() защищенный Метод

Return an instance of WPDKConfiguration class
protected __construct ( string $name )
$name string A string used as name for options. Make it unique more possible.

delete() публичный Метод

Delete this configuration
public delete ( )

delta() публичный Метод

Do a delta compare/combine from two tree object config
public delta ( ) : object
Результат object

init() публичный статический Метод

public static function init( $name = null, $class_name = null ) {
public static init ( )

update() публичный Метод

Update on database this configuration.
public update ( )