PHP Class Webiny\Component\Entity\EntityDataExtractor

Inheritance: use trait Webiny\Component\StdLib\StdLibTrait
Show file Open project: webiny/framework Class Usage Examples

Protected Properties

Property Type Description
$cache
$currentLevel
$entity AbstractEntity
$nestedLevel

Public Methods

Method Description
__construct ( AbstractEntity $entity ) Maximum depth is 10 which is hard to achieve
extractData ( array $attributes = [] ) : array Extract AbstractEntity data to array using specified list of attributes.

Private Methods

Method Description
buildEntityFields ( string | array $fields ) : array Parse fields string and build nested fields structure.
If array is given, will just return that array.
buildFields ( ArrayObject &$parsedFields, StringObject $key ) Parse attribute key recursively
buildNestedKeys ( $fields )
getDefaultAttributes ( ) : string Get default list of entity attributes.
Only simple and Many2One attributes are considered to be default attributes.
getSubAttributesFromArray ( $subAttributes, $array )
parseGroupedNestedFields ( StringObject $string ) : StringObject Check if there are grouped nested keys (by using '[' and ']' and converts that string into a plain version - a string that only contains comma-separated full paths of each field

Method Details

__construct() public method

Maximum depth is 10 which is hard to achieve
public __construct ( AbstractEntity $entity )
$entity AbstractEntity

extractData() public method

If no attributes are specified, only simple and Many2One attributes will be extracted. If you need to get One2Many and Many2Many attributes, you need to explicitly specify a list of attributes.
public extractData ( array $attributes = [] ) : array
$attributes array Ex: 'title,author.name,comments.id,comments.text'
return array

Property Details

$cache protected static property

protected static $cache

$currentLevel protected static property

protected static $currentLevel

$entity protected property

protected AbstractEntity,Webiny\Component\Entity $entity
return AbstractEntity

$nestedLevel protected property

protected $nestedLevel