Property | Type | Description | |
---|---|---|---|
$attribute | null | string | Attribute name | |
$defaultValue | null | Default value | |
$onFromDbCallback | null | The value returned from the callback will be set as attribute value | |
$onGetCallback | null | The value returned from the callback will be returned as attribute value. | |
$onSetCallback | null | The value returned from the callback will be set as a new attribute value. | |
$onSetValue | null | Value to trigger $onSetCallback | |
$onToArrayCallback | null | The value returned from the callback will be returned as attribute value. | |
$onToDbCallback | null | The value returned from the callback will be returned as attribute value for database. | |
$once | boolean | If true - updating will be disabled | |
$parent | Entity this attribute belongs to | ||
$required | boolean | Is this attribute required | |
$setAfterPopulate | boolean | If true - will wait until mass populate is finished and assign the value afterwards | |
$skipOnPopulate | boolean | If true - mass populate will skip this attribute | |
$storeToDb | boolean | If true - will store this attribute to database | |
$toArrayDefault | null | If true - this attribute will be included in the output of entity's toArray method | |
$validationMessages | array | Validation messages | |
$validatorInterface | string | ||
$validators | array | Attribute validators | |
$value | null | Actual value |
Method | Description | |
---|---|---|
__construct ( string $name = null, |
||
__toString ( ) : string | Get attribute value as string | |
attr ( null | string $attribute = null ) : |
Create new attribute or get name of current attribute | |
getAfterPopulate ( ) : boolean | Should this attribute's value be assigned after populate() ? | |
getDbValue ( ) : string |
Get value that will be stored to database |
|
getDefaultValue ( ) : mixed | Get default value | |
getName ( ) : string | Get attribute name | |
getOnce ( ) |
Get 'once' flag This flag tells you whether this attribute should only be populated when it's a new AbstractEntity instance. By default, attributes are populated each time. |
|
getParent ( ) : |
Get entity instance this attribute belongs to | |
getSkipOnPopulate ( ) : boolean | Get skipOnPopulate flag | |
getStoreToDb ( ) : boolean | Should this attribute value be stored to DB | |
getToArrayDefault ( ) : boolean | Get toArrayDefault flag | |
getValidationMessages ( string | null $validator = null ) : mixed | Get validation messages | |
getValidators ( ) : array | Get validators | |
getValue ( array $params = [], boolean $processCallbacks = true ) | Get attribute value | |
hasToArrayCallback ( ) | ||
hasValue ( ) | ||
isRequired ( ) | Get required flag | |
jsonSerialize ( ) : mixed |
(PHP 5 >= 5.4.0) Specify data which should be serialized to JSON |
|
onFromDb ( $callback ) | Set callback that will be used to process value when data is loaded from DB | |
onGet ( $callable = null ) | ||
onSet ( $value, $callable = null ) | ||
onToArray ( $callback ) | Set callback that will be used to process getToArrayValue() call | |
onToDb ( $callback ) | Set callback that will be used to process getDbValue() call | |
setAfterPopulate ( boolean $flag = true ) | Should this attribute's value be assigned after populate() ? This is useful when onSet() callback is triggering business logic that depends on other attributes that are not yet set because populate() cycle has not yet finished and onSet() callback of current attribute is executed | |
setDefaultValue ( mixed $defaultValue = null ) | Set default value | |
setName ( string $attribute ) | Set attribute name | |
setOnce ( boolean $flag = true ) |
Set 'once' flag If true, it tells AbstractEntity to only populate this attribute if it's a new entity This is useful when you want to protect values from being populate on later updates. |
|
setParent ( |
||
setRequired ( boolean $flag = true ) | Set required flag | |
setSkipOnPopulate ( boolean $flag = true ) | Skip attribute on mass populate | |
setToArrayDefault ( boolean $flag = true ) | Set if this attribute will be by default included in the output of entity's toArray method | |
setValidationMessages ( array $messages ) | Set validation messages | |
setValidators ( array | string $validators = [] ) | Set attribute validators | |
setValue ( null $value = null, boolean $fromDb = false ) | Set attribute value | |
toArray ( array $params = [] ) : string | Get value that will be used to represent this attribute when converting AbstractEntity to array |
Method | Description | |
---|---|---|
applyValidator ( string $validator, string $key, mixed $value, array $messages = [] ) | Apply validator to given value | |
canAssign ( ) : boolean |
Check if value can be assigned to current attribute |
|
expected ( string $expecting, string $got, boolean $return = false ) : |
Throw or return attribute validation exception | |
processFromDbValue ( $value ) : mixed | Triggered when calling 'setValue()' with $fromDb=true on attribute instance | |
processGetValue ( mixed $value, array $params = [], boolean $processCallbacks = true ) : mixed | Triggered when calling 'getValue()' on attribute instance | |
processSetValue ( $value ) : mixed | Triggered when calling 'setValue()' on attribute instance | |
processToArrayValue ( $value ) : mixed | Triggered when calling 'toArray()' on the entity instance | |
processToDbValue ( $value ) : mixed | Triggered when calling 'getDbValue()' on attribute instance | |
validate ( &$value ) | Perform validation against given value |
Method | Description | |
---|---|---|
processCallback ( $callback, $value, array $params = [] ) : mixed |
Execute given callback Take $value and check if a valid callback is given If yes, return the processed value. |
public __construct ( string $name = null, |
||
$name | string | |
$parent |
public __toString ( ) : string | ||
return | string |
public getAfterPopulate ( ) : boolean | ||
return | boolean |
public getDbValue ( ) : string | ||
return | string |
public getOnce ( ) |
public getParent ( ) : |
||
return |
public getSkipOnPopulate ( ) : boolean | ||
return | boolean |
public getStoreToDb ( ) : boolean | ||
return | boolean |
public getToArrayDefault ( ) : boolean | ||
return | boolean |
public jsonSerialize ( ) : mixed | ||
return | mixed | data which can be serialized by json_encode, which is a value of any type other than a resource. |
public onFromDb ( $callback ) | ||
$callback |
public onToArray ( $callback ) | ||
$callback |
public onToDb ( $callback ) | ||
$callback |
protected processFromDbValue ( $value ) : mixed | ||
$value | ||
return | mixed |
protected processSetValue ( $value ) : mixed | ||
$value | ||
return | mixed |
protected processToArrayValue ( $value ) : mixed | ||
$value | ||
return | mixed |
protected processToDbValue ( $value ) : mixed | ||
$value | ||
return | mixed |
public setAfterPopulate ( boolean $flag = true ) | ||
$flag | boolean |
public setDefaultValue ( mixed $defaultValue = null ) | ||
$defaultValue | mixed |
public setParent ( |
||
$entity |
public setRequired ( boolean $flag = true ) | ||
$flag | boolean |
public setSkipOnPopulate ( boolean $flag = true ) | ||
$flag | boolean |
public setToArrayDefault ( boolean $flag = true ) | ||
$flag | boolean |
public setValidationMessages ( array $messages ) | ||
$messages | array |
public setValidators ( array | string $validators = [] ) | ||
$validators | array | string |
protected validate ( &$value ) | ||
$value |
protected null $onFromDbCallback | ||
return | null |
protected null $onGetCallback | ||
return | null |
protected null $onSetCallback | ||
return | null |
protected null $onSetValue | ||
return | null |
protected null $onToArrayCallback | ||
return | null |
protected null $onToDbCallback | ||
return | null |
protected AbstractEntity,Webiny\Component\Entity $parent | ||
return |
protected bool $setAfterPopulate | ||
return | boolean |
protected bool $skipOnPopulate | ||
return | boolean |
protected bool $storeToDb | ||
return | boolean |
protected null $toArrayDefault | ||
return | null |
protected array $validationMessages | ||
return | array |