PHP Class Webiny\Component\Entity\AbstractEntity

Inheritance: implements ArrayAccess, use trait Webiny\Component\StdLib\StdLibTrait, use trait EntityTrait, use trait Webiny\Component\StdLib\FactoryLoaderTrait
Afficher le fichier Open project: Webiny/Framework Class Usage Examples

Protected Properties

Свойство Type Description
$attributeBuilder EntityAttributeBuilder
$attributes Webiny\Component\StdLib\StdObject\ArrayObject\ArrayObject Entity attributes
$entityCollection Entity collection name
$entityMask string View mask (used for grids and many2one input fields)

Méthodes publiques

Méthode Description
__call ( $name, $arguments )
__construct ( ) Entity constructor
__get ( $name ) : AbstractAttribute This method allows us to use simplified accessor methods.
__set ( $name, $value ) This method allows setting attribute values through simple assignment Ex: $person->name = 'Webiny';
__toString ( ) : mixed Return string representation of entity
attr ( $attribute ) : EntityAttributeBuilder
count ( array $conditions = [] ) : integer Count records using given criteria
delete ( ) : boolean Delete entity
exists ( ) : boolean Is this entity already saved?
find ( array $conditions = [], array $order = [], integer $limit, integer $page ) : EntityCollection Find entities
findById ( $id ) : null | AbstractEntity Find entity by ID
findOne ( array $conditions = [] ) : null | AbstractEntity Find entity by array of conditions
getAttribute ( string $attribute ) : AbstractAttribute Get entity attribute
getAttributes ( ) : ArrayObject Get all entity attributes
getEntityCollection ( ) : string Get collection name
getMaskedValue ( )
latest ( integer $limit = 1 ) : mixed | null Finds one or more latest entities
offsetExists ( $offset )
offsetGet ( $offset )
offsetSet ( $offset, $value )
offsetUnset ( $offset )
populate ( array $data ) Populate entity with given data
random ( array $conditions = [] ) : null | AbstractEntity Find a random entity
save ( ) Save entity attributes to database
toArray ( string $fields = '' ) : array Convert AbstractEntity to array with specified fields.

Méthodes protégées

Méthode Description
isDbData ( $data ) : boolean Used for checking if the entity populate data is coming from database

Private Methods

Méthode Description
normalizeData ( $data )
parseOrderParameters ( $order ) : array Parse order parameters and construct parameters suitable for MongoDB
populateAttribute ( $attributeName, AbstractAttribute $entityAttribute, $validation, $data, $fromDb )

Method Details

__call() public méthode

public __call ( $name, $arguments )

__construct() public méthode

Entity constructor
public __construct ( )

__get() public méthode

Ex: $person->company->name
public __get ( $name ) : AbstractAttribute
$name
Résultat Webiny\Component\Entity\Attribute\AbstractAttribute

__set() public méthode

This method allows setting attribute values through simple assignment Ex: $person->name = 'Webiny';
public __set ( $name, $value )
$name
$value

__toString() public méthode

Return string representation of entity
public __toString ( ) : mixed
Résultat mixed

attr() public méthode

public attr ( $attribute ) : EntityAttributeBuilder
$attribute
Résultat EntityAttributeBuilder

count() public static méthode

Count records using given criteria
public static count ( array $conditions = [] ) : integer
$conditions array
Résultat integer

delete() public méthode

Delete entity
public delete ( ) : boolean
Résultat boolean

exists() public méthode

Is this entity already saved?
public exists ( ) : boolean
Résultat boolean

find() public static méthode

Find entities
public static find ( array $conditions = [], array $order = [], integer $limit, integer $page ) : EntityCollection
$conditions array
$order array Example: ['-name', '+title']
$limit integer
$page integer
Résultat EntityCollection

findById() public static méthode

Find entity by ID
public static findById ( $id ) : null | AbstractEntity
$id
Résultat null | AbstractEntity

findOne() public static méthode

Find entity by array of conditions
public static findOne ( array $conditions = [] ) : null | AbstractEntity
$conditions array
Résultat null | AbstractEntity

getAttribute() public méthode

Get entity attribute
public getAttribute ( string $attribute ) : AbstractAttribute
$attribute string
Résultat Webiny\Component\Entity\Attribute\AbstractAttribute

getAttributes() public méthode

Get all entity attributes
public getAttributes ( ) : ArrayObject
Résultat Webiny\Component\StdLib\StdObject\ArrayObject\ArrayObject

getEntityCollection() public static méthode

Get collection name
public static getEntityCollection ( ) : string
Résultat string

getMaskedValue() public méthode

public getMaskedValue ( )

isDbData() protected méthode

Used for checking if the entity populate data is coming from database
protected isDbData ( $data ) : boolean
$data
Résultat boolean

latest() public static méthode

Finds one or more latest entities
public static latest ( integer $limit = 1 ) : mixed | null
$limit integer
Résultat mixed | null

offsetExists() public méthode

public offsetExists ( $offset )

offsetGet() public méthode

public offsetGet ( $offset )

offsetSet() public méthode

public offsetSet ( $offset, $value )

offsetUnset() public méthode

public offsetUnset ( $offset )

populate() public méthode

Populate entity with given data
public populate ( array $data )
$data array

random() public static méthode

Find a random entity
public static random ( array $conditions = [] ) : null | AbstractEntity
$conditions array
Résultat null | AbstractEntity

save() public méthode

Save entity attributes to database
public save ( )

toArray() public méthode

If no fields are specified, array will contain all simple and Many2One attributes
public toArray ( string $fields = '' ) : array
$fields string List of fields to extract
Résultat array

Property Details

$attributeBuilder protected_oe property

protected EntityAttributeBuilder,Webiny\Component\Entity $attributeBuilder
Résultat EntityAttributeBuilder

$attributes protected_oe property

Entity attributes
protected ArrayObject,Webiny\Component\StdLib\StdObject\ArrayObject $attributes
Résultat Webiny\Component\StdLib\StdObject\ArrayObject\ArrayObject

$entityCollection protected_oe static_oe property

Entity collection name
protected static $entityCollection

$entityMask protected_oe static_oe property

View mask (used for grids and many2one input fields)
protected static string $entityMask
Résultat string