From ba36d0806a56f77660fd533ec6aa8cc5a10010a2 Mon Sep 17 00:00:00 2001 From: Kirtan Gajjar Date: Wed, 14 Jul 2021 16:22:27 +0530 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=EF=B8=8F=20Add=20cache=20update=20fea?= =?UTF-8?q?ture?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- php/EE/Model/Base.php | 53 ++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 52 insertions(+), 1 deletion(-) 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 *