From a5acbc7bffa8d7bf70ffb969d26d8a767325f677 Mon Sep 17 00:00:00 2001 From: Samuel Georges Date: Wed, 27 Apr 2016 05:43:55 +1000 Subject: [PATCH] Add before/after events for component::onRun --- modules/cms/classes/CmsCompoundObject.php | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/modules/cms/classes/CmsCompoundObject.php b/modules/cms/classes/CmsCompoundObject.php index a7aeefe3a..9aa36b2a7 100644 --- a/modules/cms/classes/CmsCompoundObject.php +++ b/modules/cms/classes/CmsCompoundObject.php @@ -163,9 +163,17 @@ class CmsCompoundObject extends CmsObject public function runComponents() { foreach ($this->components as $component) { + if ($event = $component->fireEvent('component.beforeRun', [], true)) { + return $event; + } + if ($result = $component->onRun()) { return $result; } + + if ($event = $component->fireEvent('component.run', [], true)) { + return $event; + } } } @@ -429,6 +437,22 @@ class CmsCompoundObject extends CmsObject return parent::__get($name); } + /** + * Dynamically set attributes on the model. + * + * @param string $key + * @param mixed $value + * @return void + */ + public function __set($key, $value) + { + parent::__set($key, $value); + + if (array_key_exists($key, $this->settings)) { + $this->settings[$key] = $this->attributes[$key]; + } + } + /** * Determine if an attribute exists on the object. *