/** * 构造函数,默认启动埋在此钩子下的扩展服务 * * @param string $hookKey 钩子点,默认为类名 * @param string $interface * @param object $srv * @return void */ private function __construct($hookKey) { if (!($hooks = PwHook::getRegistry('s_' . $hookKey))) { return; } if (!($map = PwHook::resolveActionHook($hooks))) { return; } foreach ($map as $key => $value) { $this->appendDo(Wekit::getInstance($value['class'], $value['loadway']), $value['method']); } }
/** * 初始化 */ private function init($clearType) { $types = $this->getClearTypes(); $num = 0; foreach ($clearType as $item) { $_type = isset($types[$item]) ? $types[$item] : array(); if (!$_type || !$_type['class']) { continue; } /* @var $instance iPwDoHookProcess */ $this->appendDo(Wekit::getInstance($_type['class'], 'load')); $num++; } return $num; }
protected function _prepare() { if ($this->_ready) { return !empty($this->_do); } !$this->_srv && ($this->_srv = $this); foreach ($this->_key as $key => $hookKey) { if (!($hooks = PwHook::getRegistry($hookKey))) { continue; } if (!($map = PwHook::resolveActionHook($hooks, $this->_srv))) { continue; } foreach ($map as $key => $value) { $this->appendDo(Wekit::getInstance($value['class'], $value['loadway'], array($this->_srv))); } } $this->_ready = true; return !empty($this->_do); }