Exemple #1
0
 /**
  * Creates decorator
  *
  * @param object $oComponent
  * @param bool   $bHookEnable
  *
  * @return Decorator
  */
 static function Create($oComponent, $bHookEnable = true)
 {
     $sClassName = get_class($oComponent);
     if (!$bHookEnable || $sClassName == 'ModulePlugin' || $sClassName == 'ModuleHook') {
         return $oComponent;
     }
     if (DEBUG) {
         $sDecoratorClassName = 'Decorator' . $sClassName;
         $sDecoratorClassCode = 'class ' . $sDecoratorClassName . ' extends Decorator { }';
         eval($sDecoratorClassCode);
         $oComponentDecorator = new $sDecoratorClassName($oComponent);
     } else {
         $oComponentDecorator = new static($oComponent);
     }
     $aClassInfo = E::GetClassInfo($oComponent, Engine::CI_ACTION | Engine::CI_MODULE);
     if ($aClassInfo[Engine::CI_ACTION]) {
         $oComponentDecorator->setType('action');
         $oComponentDecorator->setName($aClassInfo[Engine::CI_ACTION]);
         $oComponentDecorator->setHookEnable(true);
     } elseif ($aClassInfo[Engine::CI_MODULE]) {
         $oComponentDecorator->setType('module');
         $oComponentDecorator->setName($aClassInfo[Engine::CI_MODULE]);
         $oComponentDecorator->setHookEnable(true);
     }
     return $oComponentDecorator;
 }
Exemple #2
0
 /**
  * Creates decorator
  *
  * @param object $oComponent
  * @param bool   $bHookEnable
  *
  * @return object
  */
 static function Create($oComponent, $bHookEnable = true)
 {
     $sClassName = get_class($oComponent);
     if (!$bHookEnable || $sClassName == 'ModulePlugin' || $sClassName == 'ModuleHook') {
         return $oComponent;
     }
     $oComponentDecorator = new static($oComponent);
     $aClassInfo = E::GetClassInfo($oComponent, Engine::CI_ACTION | Engine::CI_MODULE);
     if ($aClassInfo[Engine::CI_ACTION]) {
         $oComponentDecorator->setType('action');
         $oComponentDecorator->setName($aClassInfo[Engine::CI_ACTION]);
         $oComponentDecorator->setHookEnable(true);
     } elseif ($aClassInfo[Engine::CI_MODULE]) {
         $oComponentDecorator->setType('module');
         $oComponentDecorator->setName($aClassInfo[Engine::CI_MODULE]);
         $oComponentDecorator->setHookEnable(true);
     }
     return $oComponentDecorator;
 }
Exemple #3
0
 /**
  * Автозагрузка классов
  *
  * @param string $sClassName    Название класса
  *
  * @return bool
  */
 public static function Autoload($sClassName)
 {
     if ($sParentClass = Config::Get('classes.alias.' . $sClassName)) {
         return self::_classAlias($sParentClass, $sClassName);
     }
     if (self::_autoloadDefinedClass($sClassName)) {
         return true;
     }
     if (class_exists('Engine', false) && E::GetStage() >= E::STAGE_INIT) {
         $aInfo = E::GetClassInfo($sClassName, E::CI_CLASSPATH | E::CI_INHERIT);
         if ($aInfo[E::CI_INHERIT]) {
             $sInheritClass = $aInfo[E::CI_INHERIT];
             $sParentClass = E::ModulePlugin()->GetParentInherit($sInheritClass);
             return self::_classAlias($sParentClass, $sClassName);
         } elseif ($aInfo[E::CI_CLASSPATH]) {
             return self::_includeFile($aInfo[E::CI_CLASSPATH], $sClassName);
         }
     }
     if (self::_autoloadPSR($sClassName)) {
         return true;
     }
     return false;
 }
Exemple #4
0
 /**
  * Проксирует вызов методов в модуль сущности
  *
  * @param string $sName    Название метода
  *
  * @return mixed
  */
 protected function _Method($sName)
 {
     $sModuleName = E::GetModuleName($this);
     $sEntityName = E::GetEntityName($this);
     $sPluginPrefix = E::GetPluginPrefix($this);
     /**
      * If Module not exists, try to find its root Delegater
      */
     $aClassInfo = E::GetClassInfo($sPluginPrefix . 'Module_' . $sModuleName, Engine::CI_MODULE);
     if (empty($aClassInfo[E::CI_MODULE]) && ($sRootDelegater = E::ModulePlugin()->GetRootDelegater('entity', get_class($this)))) {
         $sModuleName = E::GetModuleName($sRootDelegater);
         $sPluginPrefix = E::GetPluginPrefix($sRootDelegater);
     }
     $aCallArgs = array($this);
     return E::GetInstance()->_CallModule("{$sPluginPrefix}{$sModuleName}_{$sName}{$sEntityName}", $aCallArgs);
 }