From c97e352ea2b2f2fc5d6dd1085e560114cd05cb29 Mon Sep 17 00:00:00 2001 From: Sam Georges Date: Sat, 24 May 2014 13:27:26 +1000 Subject: [PATCH] Fixes #206 --- modules/cms/classes/CmsObject.php | 48 +++++++++++++++++++++++++- modules/cms/classes/CmsObjectQuery.php | 3 ++ 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/modules/cms/classes/CmsObject.php b/modules/cms/classes/CmsObject.php index 9d10d0f3b..b8dbe87ae 100644 --- a/modules/cms/classes/CmsObject.php +++ b/modules/cms/classes/CmsObject.php @@ -11,6 +11,7 @@ use October\Rain\Support\ValidationException; use Exception; use RecursiveIteratorIterator; use RecursiveDirectoryIterator; +use ArrayAccess; /** * This is a base class for all CMS objects - content files, pages, partials and layouts. @@ -19,7 +20,7 @@ use RecursiveDirectoryIterator; * @package october\cms * @author Alexey Bobkov, Samuel Georges */ -class CmsObject +class CmsObject implements ArrayAccess { /** * @var string Specifies the file name corresponding the CMS object. @@ -435,6 +436,51 @@ class CmsObject return false; } + /** + * Determine if the given attribute exists. + * + * @param mixed $offset + * @return bool + */ + public function offsetExists($offset) + { + return isset($this->$offset); + } + + /** + * Get the value for a given offset. + * + * @param mixed $offset + * @return mixed + */ + public function offsetGet($offset) + { + return $this->$offset; + } + + /** + * Set the value for a given offset. + * + * @param mixed $offset + * @param mixed $value + * @return void + */ + public function offsetSet($offset, $value) + { + $this->$offset = $value; + } + + /** + * Unset the value for a given offset. + * + * @param mixed $offset + * @return void + */ + public function offsetUnset($offset) + { + unset($this->$offset); + } + // // Queries // diff --git a/modules/cms/classes/CmsObjectQuery.php b/modules/cms/classes/CmsObjectQuery.php index 4a147745d..83e2c2824 100644 --- a/modules/cms/classes/CmsObjectQuery.php +++ b/modules/cms/classes/CmsObjectQuery.php @@ -85,6 +85,9 @@ class CmsObjectQuery */ public function __call($method, $parameters) { + if (!method_exists('Cms\Classes\CmsObjectCollection', $method)) + return; + $collection = $this->all(); return call_user_func_array(array($collection, $method), $parameters); }