コード例 #1
0
ファイル: Hook.php プロジェクト: edouardtack/hook
 /**
  * Call method
  * Call the right method when wa add a new hook or we we call a register hook
  *
  * @param string $name Unique hook name
  * @param array $arguments
  *
  * @return void
  */
 public function __call(string $name, array $arguments)
 {
     if (preg_match('#^(set)#', $name)) {
         $name = HookHelper::camelize(HookHelper::unCamelize(substr($name, 3)));
         $this->_hookRegistry->set($name, $arguments[0], $arguments[1], $arguments[2]);
     } else {
         return $this->_call($name, $arguments);
     }
 }
コード例 #2
0
ファイル: HookRegistry.php プロジェクト: edouardtack/hook
 /**
  * Look for the function to call
  * when we call {HOOK}->TYPE();
  *
  * @param string $name Unique name of the HOOK
  * @param string $arguments Parameters send
  *
  * @return array What we have to execute
  */
 public function __call(string $name, array $arguments)
 {
     list($get, $type, $name) = explode('_', $name);
     $name = strtolower($name);
     if (!in_array(strtolower($type), $this->getTypes())) {
         throw new UnavailableHookException("Type : " . $type . " is not availble. Types available are " . implode(', ', $this->getTypes()));
     }
     $type = HookHelper::camelize(HookHelper::unCamelize($type));
     if (isset($this->registerHooks[$type][$name])) {
         return $this->registerHooks[$type][$name];
     } else {
         return false;
     }
 }