AttributesTrait

Description

Forwards ArrayAccess to an EAV array property named $attributes.

ArrayAccess must be implemented by the class using this trait. The $attributes property must also be defined in the class, and annotated with @eav <TABLE>.

The instance must have its attributes loaded before use as an array, otherwise existing EAV data may be lost when the instance is saved. Attribute loading is done automatically by Record.

See also
Record::load()

Protected Properties

array $attributes
 

Public Methods

scalar[] getAttributes ()
 
bool offsetExists ($attr)
 
null scalar offsetGet ($attr)
 
void offsetSet ($attr, $value)
 
void offsetUnset ($attr)
 
$this setAttributes (array $attributes)
 

Methods

◆ getAttributes()

scalar [] getAttributes ( )
Returns
scalar[]

◆ offsetExists()

bool offsetExists (   $attr)
Parameters
mixed$attr
Returns
bool

◆ offsetGet()

null scalar offsetGet (   $attr)
Parameters
mixed$attr
Returns
null|scalar

◆ offsetSet()

void offsetSet (   $attr,
  $value 
)
Parameters
mixed$attr
null | scalar$value

◆ offsetUnset()

void offsetUnset (   $attr)
Parameters
mixed$attr

◆ setAttributes()

$this setAttributes ( array  $attributes)
Parameters
scalar[]$attributes
Returns
$this