Magento 2 Documentation
2.3
Documentation for Magento 2 CMS v2.3 (December 2018)
|
Data Structures | |
class | CopyTest |
Public Member Functions | |
__construct (array $data=[]) | |
addData (array $arr) | |
setData ($key, $value=null) | |
unsetData ($key=null) | |
getData ($key='', $index=null) | |
getDataByPath ($path) | |
getDataByKey ($key) | |
setDataUsingMethod ($key, $args=[]) | |
getDataUsingMethod ($key, $args=null) | |
hasData ($key='') | |
toArray (array $keys=[]) | |
convertToArray (array $keys=[]) | |
toXml (array $keys=[], $rootName='item', $addOpenTag=false, $addCdata=true) | |
convertToXml (array $arrAttributes=[], $rootName='item', $addOpenTag=false, $addCdata=true) | |
toJson (array $keys=[]) | |
convertToJson (array $keys=[]) | |
toString ($format='') | |
__call ($method, $args) | |
isEmpty () | |
serialize ($keys=[], $valueSeparator='=', $fieldSeparator=' ', $quote='"') | |
debug ($data=null, &$objects=[]) | |
offsetSet ($offset, $value) | |
offsetExists ($offset) | |
offsetUnset ($offset) | |
offsetGet ($offset) | |
Protected Member Functions | |
_getData ($key) | |
_underscore ($name) | |
Protected Attributes | |
$_data = [] | |
Static Protected Attributes | |
static | $_underscoreCache = [] |
Universal data container with array access implementation
@api @SuppressWarnings(PHPMD.NumberOfChildren)
Definition at line 15 of file DataObject.php.
__construct | ( | array | $data = [] | ) |
Constructor
By default is looking for first argument as array and assigns it as object attributes This behavior may change in child classes
array | $data |
Definition at line 39 of file DataObject.php.
__call | ( | $method, | |
$args | |||
) |
Set/Get attribute wrapper
string | $method | |
array | $args |
Definition at line 380 of file DataObject.php.
|
protected |
Get value from _data array without parse key
string | $key |
Definition at line 189 of file DataObject.php.
|
protected |
Converts field names for setters and getters
$this->setMyField($value) === $this->setData('my_field', $value) Uses cache to eliminate unnecessary preg_replace
string | $name |
Definition at line 425 of file DataObject.php.
addData | ( | array | $arr | ) |
Add data to the object.
Retains previous data in the object.
array | $arr |
Definition at line 52 of file DataObject.php.
convertToArray | ( | array | $keys = [] | ) |
The "__" style wrapper for toArray method
array | $keys |
Definition at line 268 of file DataObject.php.
convertToJson | ( | array | $keys = [] | ) |
The "__" style wrapper for toJson
array | $keys |
Definition at line 345 of file DataObject.php.
convertToXml | ( | array | $arrAttributes = [] , |
$rootName = 'item' , |
|||
$addOpenTag = false , |
|||
$addCdata = true |
|||
) |
The "__" style wrapper for toXml method
array | $arrAttributes | array of keys that must be represented |
string | $rootName | root node name |
bool | $addOpenTag | flag that allow to add initial xml node |
bool | $addCdata | flag that require wrap all values in CDATA |
Definition at line 316 of file DataObject.php.
debug | ( | $data = null , |
|
& | $objects = [] |
||
) |
Present object data as string in debug mode
mixed | $data | |
array | &$objects |
Definition at line 469 of file DataObject.php.
getData | ( | $key = '' , |
|
$index = null |
|||
) |
Object data getter
If $key is not defined will return all the data as an array. Otherwise it will return value of the element specified by $key. It is possible to use keys like a/b/c for access nested array data
If $index is specified it will assume that attribute data is an array and retrieve corresponding member. If data is the string - it will be explode by new line character and converted to array.
string | $key | |
string | int | $index |
Definition at line 119 of file DataObject.php.
getDataByKey | ( | $key | ) |
Get object data by particular key
string | $key |
Definition at line 178 of file DataObject.php.
getDataByPath | ( | $path | ) |
Get object data by path
Method consider the path as chain of keys: a/b/c => ['a']['b']['c']
string | $path |
Definition at line 155 of file DataObject.php.
getDataUsingMethod | ( | $key, | |
$args = null |
|||
) |
Get object data by key with calling getter method
string | $key | |
mixed | $args |
Definition at line 218 of file DataObject.php.
hasData | ( | $key = '' | ) |
If $key is empty, checks whether there's any data in the object Otherwise checks if the specified attribute is set.
string | $key |
Definition at line 231 of file DataObject.php.
isEmpty | ( | ) |
offsetExists | ( | $offset | ) |
Implementation of \ArrayAccess::offsetExists()
string | $offset |
Definition at line 512 of file DataObject.php.
offsetGet | ( | $offset | ) |
Implementation of \ArrayAccess::offsetGet()
string | $offset |
Definition at line 536 of file DataObject.php.
offsetSet | ( | $offset, | |
$value | |||
) |
Implementation of \ArrayAccess::offsetSet()
string | $offset | |
mixed | $value |
Definition at line 500 of file DataObject.php.
offsetUnset | ( | $offset | ) |
Implementation of \ArrayAccess::offsetUnset()
string | $offset |
Definition at line 524 of file DataObject.php.
serialize | ( | $keys = [] , |
|
$valueSeparator = '=' , |
|||
$fieldSeparator = ' ' , |
|||
$quote = '"' |
|||
) |
Convert object data into string with defined keys and values.
Example: key1="value1" key2="value2" ...
array | $keys | array of accepted keys |
string | $valueSeparator | separator between key and value |
string | $fieldSeparator | separator between key/value pairs |
string | $quote | quoting sign |
Definition at line 446 of file DataObject.php.
setData | ( | $key, | |
$value = null |
|||
) |
Overwrite data in the object.
The $key parameter can be string or array. If $key is string, the attribute value will be overwritten by $value
If $key is an array, it will overwrite all the data in the object.
string | array | $key | |
mixed | $value |
Definition at line 72 of file DataObject.php.
setDataUsingMethod | ( | $key, | |
$args = [] |
|||
) |
Set object data with calling setter method
string | $key | |
mixed | $args |
Definition at line 204 of file DataObject.php.
toArray | ( | array | $keys = [] | ) |
Convert array of object data with to array with keys requested in $keys array
array | $keys | array of required keys |
Definition at line 245 of file DataObject.php.
toJson | ( | array | $keys = [] | ) |
Convert object data to JSON
array | $keys | array of required keys |
Definition at line 332 of file DataObject.php.
toString | ( | $format = '' | ) |
Convert object data into string with predefined format
Will use $format as an template and substitute {{key}} for attributes
string | $format |
Definition at line 358 of file DataObject.php.
toXml | ( | array | $keys = [] , |
$rootName = 'item' , |
|||
$addOpenTag = false , |
|||
$addCdata = true |
|||
) |
Convert object data into XML string
array | $keys | array of keys that must be represented |
string | $rootName | root node name |
bool | $addOpenTag | flag that allow to add initial xml node |
bool | $addCdata | flag that require wrap all values in CDATA |
Definition at line 282 of file DataObject.php.
unsetData | ( | $key = null | ) |
Unset data from the object.
null | string | array | $key |
Definition at line 88 of file DataObject.php.
|
protected |
Definition at line 22 of file DataObject.php.
|
staticprotected |
Definition at line 29 of file DataObject.php.