PHP Class mtv\models\Model

You can access the fields on a model object in the following ways: $post->field_name; $post->attributes['field_name']; If you need an array of the fields on a model object, do this: $data = $post->attributes;
Exibir arquivo Open project: newsapps/wordpress-mtv Class Usage Examples

Public Properties

Property Type Description
$attributes Where the model's data is stored
$cache_groups WP Object Cache groups this model is associated with
$collection
$defaults Default model data used when a new model is created
$editable_json_fields Attributes that can be updated over the wire
$json_fields Attributes that are OK to send over the wire

Protected Properties

Property Type Description
$_previous_attributes Attributes that have been changed since the last save or fetch
$_synchronized Is this model's data sync'd with the DB?

Public Methods

Method Description
__construct ( $args = [] )
__get ( $name )
__isset ( $name )
__set ( $name, $val )
__toString ( )
__unset ( $name )
clear ( ) Delete all the attributes in this model
fetch ( ) Populate this model from permanent storage
from_json ( &$data ) Create a new model from json data sent over the wire
initialize ( $args ) Call initialize when the model is created
parse ( &$data ) Process the raw data from permanent storage
reload ( &$data ) Update this model with data from permanent storage
save ( ) Write the data in this model to permanent storage
set ( $args, $fetching = false ) Set a bunch of attributes at once
set_from_json ( &$data ) Update this model from json data sent over the wire
to_json ( ) Returns an assoc array of this model's data to send over the wire
validate ( ) Validate the data in this model
values ( ) Returns an array of selected values TODO: Return all values if no params are given

Method Details

__construct() public method

public __construct ( $args = [] )

__get() public method

public __get ( $name )

__isset() public method

public __isset ( $name )

__set() public method

public __set ( $name, $val )

__toString() public method

public __toString ( )

__unset() public method

public __unset ( $name )

clear() public method

Delete all the attributes in this model
public clear ( )

fetch() public method

Populate this model from permanent storage
public fetch ( )

from_json() public static method

Create a new model from json data sent over the wire
public static from_json ( &$data )

initialize() public method

Call initialize when the model is created
public initialize ( $args )

parse() public method

Process the raw data from permanent storage
public parse ( &$data )

reload() public method

Update this model with data from permanent storage
public reload ( &$data )

save() public method

Write the data in this model to permanent storage
public save ( )

set() public method

Set a bunch of attributes at once
public set ( $args, $fetching = false )

set_from_json() public method

Update this model from json data sent over the wire
public set_from_json ( &$data )

to_json() public method

Returns an assoc array of this model's data to send over the wire
public to_json ( )

validate() public method

Validate the data in this model
public validate ( )

values() public method

Returns an array of selected values TODO: Return all values if no params are given
public values ( )

Property Details

$_previous_attributes protected_oe property

Attributes that have been changed since the last save or fetch
protected $_previous_attributes

$_synchronized protected_oe property

Is this model's data sync'd with the DB?
protected $_synchronized

$attributes public_oe property

Where the model's data is stored
public $attributes

$cache_groups public_oe property

WP Object Cache groups this model is associated with
public $cache_groups

$collection public_oe static_oe property

public static $collection

$defaults public_oe property

Default model data used when a new model is created
public $defaults

$editable_json_fields public_oe property

Attributes that can be updated over the wire
public $editable_json_fields

$json_fields public_oe property

Attributes that are OK to send over the wire
public $json_fields