Свойство | Тип | Описание | |
---|---|---|---|
$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 |
Метод | Описание | |
---|---|---|
__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 |
Метод | Описание | |
---|---|---|
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 |
Метод | Описание | |
---|---|---|
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 | ||
Результат | string |
public getAfterPopulate ( ) : boolean | ||
Результат | boolean |
public getDbValue ( ) : string | ||
Результат | string |
public getDefaultValue ( ) : mixed | ||
Результат | mixed |
public getOnce ( ) |
public getParent ( ) : |
||
Результат |
public getSkipOnPopulate ( ) : boolean | ||
Результат | boolean |
public getStoreToDb ( ) : boolean | ||
Результат | boolean |
public getToArrayDefault ( ) : boolean | ||
Результат | boolean |
public jsonSerialize ( ) : mixed | ||
Результат | 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 | ||
Результат | mixed |
protected processSetValue ( $value ) : mixed | ||
$value | ||
Результат | mixed |
protected processToArrayValue ( $value ) : mixed | ||
$value | ||
Результат | mixed |
protected processToDbValue ( $value ) : mixed | ||
$value | ||
Результат | 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 | ||
Результат | null |
protected null $onGetCallback | ||
Результат | null |
protected null $onSetCallback | ||
Результат | null |
protected null $onSetValue | ||
Результат | null |
protected null $onToArrayCallback | ||
Результат | null |
protected null $onToDbCallback | ||
Результат | null |
protected bool $once | ||
Результат | boolean |
protected AbstractEntity,Webiny\Component\Entity $parent | ||
Результат |
protected bool $setAfterPopulate | ||
Результат | boolean |
protected bool $skipOnPopulate | ||
Результат | boolean |
protected bool $storeToDb | ||
Результат | boolean |
protected null $toArrayDefault | ||
Результат | null |
protected array $validationMessages | ||
Результат | array |