From 67f11ae109106bf006cd6f6480cab4b324af37e7 Mon Sep 17 00:00:00 2001 From: Mzhelskiy Maxim Date: Sun, 14 Apr 2013 09:45:47 +0700 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D1=81=D1=82=D1=83=D0=BF=20=D0=BA?= =?UTF-8?q?=20=D0=BF=D1=80=D0=B8=D0=B2=D0=B0=D1=82=D0=BD=D1=8B=D0=BC=20?= =?UTF-8?q?=D0=BC=D0=B5=D1=82=D0=BE=D0=B4=D0=B0=D0=BC=20=D0=B8=20=D1=81?= =?UTF-8?q?=D0=B2=D0=BE=D0=B9=D1=81=D1=82=D0=B2=D0=B0=D0=BC=20=D1=8D=D0=BA?= =?UTF-8?q?=D1=88=D0=B5=D0=BD=D0=B0=20=D0=B4=D0=BB=D1=8F=20=D0=BE=D0=B1?= =?UTF-8?q?=D1=80=D0=B0=D0=B1=D0=BE=D1=82=D1=87=D0=B8=D0=BA=D0=BE=D0=B2=20?= =?UTF-8?q?=D0=B5=D0=B2=D0=B5=D0=BD=D1=82=D0=BE=D0=B2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- engine/classes/Action.class.php | 10 ++++++++ engine/classes/Event.class.php | 42 +++++++++++++-------------------- 2 files changed, 26 insertions(+), 26 deletions(-) diff --git a/engine/classes/Action.class.php b/engine/classes/Action.class.php index af98444a..60a1d7be 100644 --- a/engine/classes/Action.class.php +++ b/engine/classes/Action.class.php @@ -117,6 +117,16 @@ abstract class Action extends LsObject { unset($aArgs[0]); return call_user_func_array(array($this,$sCall),$aArgs); } + /** + * Проверяет метод экшена на существование + * + * @param $sCall + * + * @return bool + */ + public function ActionCallExists($sCall) { + return method_exists($this,$sCall); + } /** * Добавляет евент в экшен * По сути является оберткой для AddEventPreg(), оставлен для простоты и совместимости с прошлыми версиями ядра diff --git a/engine/classes/Event.class.php b/engine/classes/Event.class.php index 9e29993a..85d861be 100644 --- a/engine/classes/Event.class.php +++ b/engine/classes/Event.class.php @@ -32,24 +32,14 @@ abstract class Event extends LsObject { */ protected $oAction=null; /** - * Список приватных методов экшена для проксирования из внешнего евента + * Объект для анализа структуры класса экшена * - * @var array + * @var null */ - protected $aMethodProxyAction=array( - 'GetDefaultEvent','GetEventMatch','GetParamEventMatch','GetParam','GetParams', - 'SetParam','SetTemplate','SetTemplateAction','EventNotFound', - ); + protected $oActionReflection=null; public function __construct() { - /** - * Переводим доступные методы к нижнему регистру - */ - $aMethods=array(); - foreach($this->aMethodProxyAction as $sMethod) { - $aMethods[]=strtolower($sMethod); - } - $this->aMethodProxyAction=$aMethods; + } /** @@ -59,6 +49,7 @@ abstract class Event extends LsObject { */ public function SetActionObject($oAction) { $this->oAction=$oAction; + $this->oActionReflection=new ReflectionClass($this->oAction); } /** @@ -76,31 +67,30 @@ abstract class Event extends LsObject { } public function __get($sName) { - if (property_exists($this->oAction,$sName)) { - return $this->oAction->$sName; + if ($this->oActionReflection->hasProperty($sName)) { + $oProperty = $this->oActionReflection->getProperty($sName); + $oProperty->setAccessible(true); + return $oProperty->getValue($this->oAction); } } public function __set($sName,$mValue) { - if (property_exists($this->oAction,$sName)) { - return $this->oAction->$sName=$mValue; + if ($this->oActionReflection->hasProperty($sName)) { + $oProperty = $this->oActionReflection->getProperty($sName); + $oProperty->setAccessible(true); + $oProperty->setValue($this->oAction,$mValue); } } public function __call($sName,$aArgs) { /** - * Обработка вызова приватных методов экшена + * Обработка вызова методов экшена */ - if (in_array(strtolower($sName),$this->aMethodProxyAction)) { + if ($this->oAction->ActionCallExists($sName)) { array_unshift($aArgs,$sName); return call_user_func_array(array($this->oAction,'ActionCall'),$aArgs); } - /** - * Обработка вызова публичных методов экшена - */ - if (method_exists($this->oAction,$sName)) { - return call_user_func_array(array($this->oAction,$sName),$aArgs); - } + return Engine::getInstance()->_CallModule($sName,$aArgs); } } \ No newline at end of file