PHP 클래스 WC_Data

Implemented by classes using the same CRUD(s) pattern.
저자: WooThemes
파일 보기 프로젝트 열기: woocommerce/woocommerce 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$cache_group string A group must be set to to enable caching.
$changes array Core data changes for this object.
$data array Core data for this object. Name value pairs (name + default value).
$data_store object Contains a reference to the data store for this class.
$default_data array Set to _data on construct so we can track and reset data if needed.
$extra_data array Used as a standard way for sub classes (like product types) to add additional information to an inherited class.
$id integer ID for this object.
$meta_data array Stores additonal meta data.
$object_read boolean This is false until the object is read from the DB.

공개 메소드들

메소드 설명
__construct ( integer | object | array $read ) Default constructor.
__toString ( ) : string Change data to JSON format.
add_meta_data ( string $key, string $value, boolean $unique = false ) Add meta data.
apply_changes ( ) Merge changes with data and clear.
delete ( boolean $force_delete = false ) : boolean Delete an object, set the ID to 0, and return result.
delete_meta_data ( array $key ) Delete meta data.
delete_meta_data_by_mid ( integer $mid ) Delete meta data.
get_changes ( ) : array Return data changes only.
get_data ( ) : array Returns all data for this object.
get_data_keys ( ) : array Returns array of expected data keys for this object.
get_data_store ( ) : object Get the data store.
get_extra_data_keys ( ) : array Returns all "extra" data keys for an object (for sub objects like product types).
get_id ( ) : integer Returns the unique ID for this object.
get_meta ( string $key = '', boolean $single = true, string $context = 'view' ) : mixed Get Meta Data by Key.
get_meta_data ( ) : array Get All Meta Data.
get_object_read ( ) : boolean Get object read property.
read_meta_data ( boolean $force_read = false ) Read Meta Data from the database. Ignore any internal properties.
save ( ) : integer Save should create or update based on object existance.
save_meta_data ( ) Update Meta Data in the database.
set_defaults ( ) Set all props to default values.
set_id ( integer $id ) Set ID.
set_meta_data ( array $data ) Set all meta data from array.
set_object_read ( boolean $read = true ) Set object read property.
set_props ( array $props, $context = 'set' ) : WP_Error | boolean Set a collection of props in one go, collect any errors, and return the result.
update_meta_data ( string $key, string $value, integer $meta_id = '' ) Update meta data by key or ID, if provided.

보호된 메소드들

메소드 설명
error ( string $error_code, string $error_message ) When invalid data is found, throw an exception unless reading from the DB.
filter_null_meta ( $meta ) : boolean Filter null meta values from array.
get_hook_prefix ( ) : string Prefix for action and filter hooks on data.
get_prop ( string $prop, string $context = 'view' ) : mixed Gets a prop for a getter method.
set_prop ( string $prop, mixed $value ) Sets a prop for a setter method.

메소드 상세

__construct() 공개 메소드

Default constructor.
public __construct ( integer | object | array $read )
$read integer | object | array ID to load from the DB (optional) or already queried data.

__toString() 공개 메소드

Change data to JSON format.
public __toString ( ) : string
리턴 string Data in JSON format.

add_meta_data() 공개 메소드

Add meta data.
부터: 2.6.0
public add_meta_data ( string $key, string $value, boolean $unique = false )
$key string Meta key
$value string Meta value
$unique boolean Should this be a unique key?

apply_changes() 공개 메소드

Merge changes with data and clear.
부터: 2.7.0
public apply_changes ( )

delete() 공개 메소드

Delete an object, set the ID to 0, and return result.
public delete ( boolean $force_delete = false ) : boolean
$force_delete boolean
리턴 boolean result

delete_meta_data() 공개 메소드

Delete meta data.
부터: 2.6.0
public delete_meta_data ( array $key )
$key array Meta key

delete_meta_data_by_mid() 공개 메소드

Delete meta data.
부터: 2.6.0
public delete_meta_data_by_mid ( integer $mid )
$mid integer Meta ID

error() 보호된 메소드

When invalid data is found, throw an exception unless reading from the DB.
protected error ( string $error_code, string $error_message )
$error_code string Error code.
$error_message string Error message.

filter_null_meta() 보호된 메소드

Filter null meta values from array.
protected filter_null_meta ( $meta ) : boolean
리턴 boolean

get_changes() 공개 메소드

Return data changes only.
부터: 2.7.0
public get_changes ( ) : array
리턴 array

get_data() 공개 메소드

Returns all data for this object.
public get_data ( ) : array
리턴 array

get_data_keys() 공개 메소드

Returns array of expected data keys for this object.
부터: 2.7.0
public get_data_keys ( ) : array
리턴 array

get_data_store() 공개 메소드

Get the data store.
부터: 2.7.0
public get_data_store ( ) : object
리턴 object

get_extra_data_keys() 공개 메소드

Returns all "extra" data keys for an object (for sub objects like product types).
부터: 2.7.0
public get_extra_data_keys ( ) : array
리턴 array

get_hook_prefix() 보호된 메소드

Prefix for action and filter hooks on data.
부터: 2.7.0
protected get_hook_prefix ( ) : string
리턴 string

get_id() 공개 메소드

Returns the unique ID for this object.
public get_id ( ) : integer
리턴 integer

get_meta() 공개 메소드

Get Meta Data by Key.
부터: 2.6.0
public get_meta ( string $key = '', boolean $single = true, string $context = 'view' ) : mixed
$key string
$single boolean return first found meta with key, or all with $key
$context string What the value is for. Valid values are view and edit.
리턴 mixed

get_meta_data() 공개 메소드

Get All Meta Data.
부터: 2.6.0
public get_meta_data ( ) : array
리턴 array

get_object_read() 공개 메소드

Get object read property.
public get_object_read ( ) : boolean
리턴 boolean

get_prop() 보호된 메소드

Gets the value from either current pending changes, or the data itself. Context controls what happens to the value before it's returned.
부터: 2.7.0
protected get_prop ( string $prop, string $context = 'view' ) : mixed
$prop string Name of prop to get.
$context string What the value is for. Valid values are view and edit.
리턴 mixed

read_meta_data() 공개 메소드

Read Meta Data from the database. Ignore any internal properties.
부터: 2.6.0
public read_meta_data ( boolean $force_read = false )
$force_read boolean True to force a new DB read (and update cache).

save() 공개 메소드

Save should create or update based on object existance.
public save ( ) : integer
리턴 integer

save_meta_data() 공개 메소드

Update Meta Data in the database.
부터: 2.6.0
public save_meta_data ( )

set_defaults() 공개 메소드

Set all props to default values.
public set_defaults ( )

set_id() 공개 메소드

Set ID.
public set_id ( integer $id )
$id integer

set_meta_data() 공개 메소드

Set all meta data from array.
부터: 2.6.0
public set_meta_data ( array $data )
$data array Key/Value pairs

set_object_read() 공개 메소드

Set object read property.
public set_object_read ( boolean $read = true )
$read boolean

set_prop() 보호된 메소드

This stores changes in a special array so we can track what needs saving the the DB later.
부터: 2.7.0
protected set_prop ( string $prop, mixed $value )
$prop string Name of prop to set.
$value mixed Value of the prop.

set_props() 공개 메소드

Only sets using public methods.
public set_props ( array $props, $context = 'set' ) : WP_Error | boolean
$props array Key value pairs to set. Key is the prop and should map to a setter function name.
리턴 WP_Error | boolean

update_meta_data() 공개 메소드

Update meta data by key or ID, if provided.
부터: 2.6.0
public update_meta_data ( string $key, string $value, integer $meta_id = '' )
$key string
$value string
$meta_id integer

프로퍼티 상세

$cache_group 보호되어 있는 프로퍼티

A group must be set to to enable caching.
protected string $cache_group
리턴 string

$changes 보호되어 있는 프로퍼티

Core data changes for this object.
protected array $changes
리턴 array

$data 보호되어 있는 프로퍼티

Core data for this object. Name value pairs (name + default value).
protected array $data
리턴 array

$data_store 보호되어 있는 프로퍼티

Contains a reference to the data store for this class.
protected object $data_store
리턴 object

$default_data 보호되어 있는 프로퍼티

Set to _data on construct so we can track and reset data if needed.
protected array $default_data
리턴 array

$extra_data 보호되어 있는 프로퍼티

Used as a standard way for sub classes (like product types) to add additional information to an inherited class.
protected array $extra_data
리턴 array

$id 보호되어 있는 프로퍼티

ID for this object.
protected int $id
리턴 integer

$meta_data 보호되어 있는 프로퍼티

Stores additonal meta data.
protected array $meta_data
리턴 array

$object_read 보호되어 있는 프로퍼티

This is false until the object is read from the DB.
protected bool $object_read
리턴 boolean