PHP Class Webiny\Component\Entity\Attribute\Many2OneAttribute

Inheritance: extends Webiny\Component\Entity\Attribute\AttributeAbstract, use trait Webiny\Component\StdLib\StdLibTrait
Datei anzeigen Open project: Webiny/Framework

Protected Properties

Property Type Description
$entityClass
$onDelete
$onSetNullCallback null | Closure
$updateExisting

Public Methods

Method Description
__toString ( ) : mixed | null | string Get masked entity value when instance is being converted to string
_get ( $name ) : AbstractAttribute This method allows us to use simplified access to attributes (no autocomplete).
getAttribute ( $name ) : AbstractAttribute This method allows us to chain getAttribute calls on related entities.
getDbValue ( ) : string Get value that will be stored to database
getEntity ( ) : string Get entity class for this attribute
getOnDelete ( ) : string Get action to perform when parent entity is being deleted.
getUpdateExisting ( ) : boolean Is update of existing entity allowed?
getValue ( array $params = [], boolean $processCallbacks = true ) : boolean | null | AbstractEntity Get attribute value
onSetNull ( $callable )
setEntity ( string $entityClass ) Set entity class for this attribute
setOnDelete ( string $action = 'cascade' ) Set action to perform when parent entity is being deleted.
setUpdateExisting ( boolean | true $flag = true ) Allow update of existing entity
setValue ( null $value = null, boolean $fromDb = false ) Set attribute value

Protected Methods

Method Description
validate ( &$value ) Perform validation against given value

Private Methods

Method Description
loadEntity ( $id )

Method Details

__toString() public method

Get masked entity value when instance is being converted to string
public __toString ( ) : mixed | null | string
return mixed | null | string

_get() public method

Ex: $person->company->name // Will output company name
public _get ( $name ) : AbstractAttribute
$name
return AbstractAttribute

getAttribute() public method

Ex: $person->getAttribute('company')->getAttribute('name')->getValue(); // This will output company name
public getAttribute ( $name ) : AbstractAttribute
$name
return AbstractAttribute

getDbValue() public method

Get value that will be stored to database
public getDbValue ( ) : string
return string

getEntity() public method

Get entity class for this attribute
public getEntity ( ) : string
return string

getOnDelete() public method

Get action to perform when parent entity is being deleted.
public getOnDelete ( ) : string
return string

getUpdateExisting() public method

Is update of existing entity allowed?
public getUpdateExisting ( ) : boolean
return boolean

getValue() public method

Get attribute value
public getValue ( array $params = [], boolean $processCallbacks = true ) : boolean | null | AbstractEntity
$params array
$processCallbacks boolean Process `onGet` callbacks
return boolean | null | Webiny\Component\Entity\AbstractEntity

onSetNull() public method

public onSetNull ( $callable )

setEntity() public method

Set entity class for this attribute
public setEntity ( string $entityClass )
$entityClass string

setOnDelete() public method

Set action to perform when parent entity is being deleted.
public setOnDelete ( string $action = 'cascade' )
$action string cascade|ignore Default value is 'ignore'

setUpdateExisting() public method

By default, only new Many2One records are created but updates are not allowed.
public setUpdateExisting ( boolean | true $flag = true )
$flag boolean | true

setValue() public method

Set attribute value
public setValue ( null $value = null, boolean $fromDb = false )
$value null
$fromDb boolean

validate() protected method

Perform validation against given value
protected validate ( &$value )
$value

Property Details

$entityClass protected_oe property

protected $entityClass

$onDelete protected_oe property

protected $onDelete

$onSetNullCallback protected_oe property

protected null|Closure $onSetNullCallback
return null | Closure

$updateExisting protected_oe property

protected $updateExisting