diff --git a/php/EE/Model/Base.php b/php/EE/Model/Base.php index cb187beed..8de438a30 100644 --- a/php/EE/Model/Base.php +++ b/php/EE/Model/Base.php @@ -7,7 +7,7 @@ /** * Base EE Model class. */ -abstract class Base { +abstract class Base extends \ArrayObject { /** * @var string Table that current model will write to @@ -242,6 +242,57 @@ public function __unset( $name ) { unset( $this->fields[$name] ); } + /** + * Overriding offsetGet for correct behaviour while accessing object properties by array index. + * + * @param string|int $index Name of property to check + * + * @throws \Exception + * + * @return bool + */ + public function offsetGet( $index ) { + return $this->__get( $index ); + } + + /** + * Overriding offsetSet for correct behaviour while saving object properties by array index. + * + * @param string|int $index Name of property to check + * @param mixed $value Value of property to set + * + * @throws \Exception + * + * @return bool + */ + public function offsetSet( $index, $value ) { + return $this->__set( $index, $value ); + } + + /** + * Overriding offsetGet for correct behaviour while checking array_key_exists. + * + * @param string|int $index Name of property to check + * + * @throws \Exception + * + * @return bool + */ + public function offsetExists( $index ) { + return $this->__isset( $index ); + } + + /** + * Overriding offsetUnset for correct behaviour while deleting object properties by array index. + * + * @param string|int $index Name of property to check + * + * @throws \Exception + */ + public function offsetUnset( $index ) { + $this->__unset( $index ); + } + /** * Saves current model into database *