PHP 클래스 WPDKConfig

## Overview You rarely (never) instantiate WPDKConfig object directly. Instead, you instantiate subclasses of the WPDKConfig class. ### Getting started Write a your own custom class and extends WPDKConfig. For example: class MySettings extends WPDKConfig { } You have to implement two methods. The first method is static: class MySettings extends WPDKConfig { const CONFIGURATION_NAME = 'mysetting-config'; static function config() { $config = parent::config( self::CONFIGURATION_NAME, __CLASS__ ); return $config; } } If you have sub branch, implements defaults() method to create these classes: class MySettings extends WPDKConfig { public $my_setting_branch; static function config() { $config = parent::config( self::CONFIGURATION_NAME, __CLASS__ ); return $config; } function defaults() { $this->my_setting_branch = new MySettingsBranch(); } } class MySettingsBranch extends WPDKConfigBranch { public $number_of_seat; function __construct() { $this->number_of_seat = 10; // Deafaul value } } ### Developing When you are in develop your settings change and the store object on db could be different from last develop version. So, just add a simple static method doDelta() for merge and combine the last onfly version with stored 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. class MySettings extends WPDKConfig { public $my_setting_branch; static function config() { $config = parent::config( self::CONFIGURATION_NAME, __CLASS__ ); return $config; } function defaults() { $this->my_setting_branch = new MySettingsBranch(); } static function doDelta() { parent::delta( self::CONFIGURATION_NAME, __CLASS__ ); } } class MySettingsBranch extends WPDKConfigBranch { public $number_of_seat; function __construct() { $this->number_of_seat = 10; // Deafaul value } } ### Reset to default To reset to default all config use MySettings::config()->resetToDefault(); ### Reset to default a branch To reset to default a single branch use MySettings::config()->my_setting_branch->defaults(); MySettings::config()->update(); See WPDKConfigBranch class for detail
사용 중단: Since 0.6.2 - Use WPDKConfiguration instead
저자: =undo= ([email protected])
파일 보기 프로젝트 열기: wpxtreme/wpdk 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$class_name string External Class name
$config_name string Unique name for this config

공개 메소드들

메소드 설명
config ( string $config_name, string $class_name ) : WPDKConfig Return an singleton instance of WPXtremeConfig subclass as specified in param inputs. This method create a single instance of parent/subclasses named $class_name.
defaults ( ) This is an override method
delta ( string $config_name, string $class_name ) Do a delta compare/combine from two tree object config
resetToDeafult ( ) Reset the configuration to head and update
update ( ) Update on database this configuration from root pointer.

비공개 메소드들

메소드 설명
__construct ( string $config_name ) : WPDKConfig Create a WPDKConfig instance

메소드 상세

config() 정적인 공개 메소드

Return an singleton instance of WPXtremeConfig subclass as specified in param inputs. This method create a single instance of parent/subclasses named $class_name.
static public config ( string $config_name, string $class_name ) : WPDKConfig
$config_name string Unique string id
$class_name string Class name
리턴 WPDKConfig

defaults() 공개 메소드

This is an override method
public defaults ( )

delta() 공개 정적인 메소드

Do a delta compare/combine from two tree object config
public static delta ( string $config_name, string $class_name )
$config_name string Unique string id
$class_name string Class name

resetToDeafult() 공개 메소드

Reset the configuration to head and update
public resetToDeafult ( )

update() 공개 메소드

Update on database this configuration from root pointer.
public update ( )

프로퍼티 상세

$class_name 공개적으로 프로퍼티

External Class name
public string $class_name
리턴 string

$config_name 공개적으로 프로퍼티

Unique name for this config
public string $config_name
리턴 string