Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨️ Add cache update feature #1550

Open
wants to merge 2 commits into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
53 changes: 52 additions & 1 deletion php/EE/Model/Base.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
/**
* Base EE Model class.
*/
abstract class Base {
abstract class Base extends \ArrayObject {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was needed for site type PHP and wp where some existing methods were called. Those methods were called in site create too where they use array index to access properties. In site update, we use object property accessor to get the values.


/**
* @var string Table that current model will write to
Expand Down Expand Up @@ -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
*
Expand Down