Пример #1
0
 /**
  * Calls method of decorated object
  *
  * @param string $sMethod
  * @param array  $aArgs
  *
  * @return mixed
  */
 public function CallMethod($sMethod, $aArgs)
 {
     $sHookMethod = $this->sHookPrefix . strtolower($sMethod);
     if ($this->bHookEnable) {
         if (!$this->oModuleHook) {
             $this->_initHooks();
         }
         switch ($this->sType) {
             case 'action':
                 $this->hookBeforeAction();
                 break;
             case 'module':
                 $sHookName = $sHookMethod . '_before';
                 if (isset($this->aRegisteredHooks[$sHookName])) {
                     $this->oModuleHook->Run($sHookName, $aArgs);
                 }
                 break;
             default:
                 break;
         }
     }
     switch (count($aArgs)) {
         case 0:
             $xResult = $this->oComponent->{$sMethod}();
             break;
         case 1:
             $xResult = $this->oComponent->{$sMethod}($aArgs[0]);
             break;
         case 2:
             $xResult = $this->oComponent->{$sMethod}($aArgs[0], $aArgs[1]);
             break;
         case 3:
             $xResult = $this->oComponent->{$sMethod}($aArgs[0], $aArgs[1], $aArgs[2]);
             break;
         case 4:
             $xResult = $this->oComponent->{$sMethod}($aArgs[0], $aArgs[1], $aArgs[2], $aArgs[3]);
             break;
         case 5:
             $xResult = $this->oComponent->{$sMethod}($aArgs[0], $aArgs[1], $aArgs[2], $aArgs[3], $aArgs[4]);
             break;
         case 6:
             $xResult = $this->oComponent->{$sMethod}($aArgs[0], $aArgs[1], $aArgs[2], $aArgs[3], $aArgs[4], $aArgs[5]);
             break;
         case 7:
             $xResult = $this->oComponent->{$sMethod}($aArgs[0], $aArgs[1], $aArgs[2], $aArgs[3], $aArgs[4], $aArgs[5], $aArgs[6]);
             break;
         case 8:
             $xResult = $this->oComponent->{$sMethod}($aArgs[0], $aArgs[1], $aArgs[2], $aArgs[3], $aArgs[4], $aArgs[5], $aArgs[6], $aArgs[7]);
             break;
         case 9:
             $xResult = $this->oComponent->{$sMethod}($aArgs[0], $aArgs[1], $aArgs[2], $aArgs[3], $aArgs[4], $aArgs[5], $aArgs[6], $aArgs[7], $aArgs[8]);
             break;
         default:
             $xResult = call_user_func_array(array($this->oComponent, $sMethod), $aArgs);
     }
     if ($this->bHookEnable) {
         switch ($this->sType) {
             case 'action':
                 $this->hookAfterAction();
                 break;
             case 'module':
                 $sHookName = $sHookMethod . '_after';
                 if (isset($this->aRegisteredHooks[$sHookName])) {
                     $aHookParams = array('result' => &$xResult, 'params' => &$aArgs);
                     $this->oModuleHook->Run($sHookName, $aHookParams);
                 }
                 break;
             default:
                 break;
         }
     }
     return $xResult;
 }
Пример #2
0
 /**
  * Declares an association between this object and a ModuleHook object.
  *
  * @param      ModuleHook $v
  * @return     Module The current object (for fluent API support)
  * @throws     PropelException
  */
 public function setModuleHook(ModuleHook $v = null)
 {
     if ($v === null) {
         $this->setHook(NULL);
     } else {
         $this->setHook($v->getId());
     }
     $this->aModuleHook = $v;
     // Add binding for other direction of this n:n relationship.
     // If this object has already been added to the ModuleHook object, it will not be re-added.
     if ($v !== null) {
         $v->addModule($this);
     }
     return $this;
 }