<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Hook; use ModStart\Core\Exception\BizException; class ModStartHook { private static $listeners = array(); public static function subscribe($c6VKG, $k3w31) { if (!is_array($c6VKG)) { $c6VKG = array($c6VKG); } foreach ($c6VKG as $yFnpO) { if (!isset(self::$listeners[$yFnpO])) { self::$listeners[$yFnpO] = array(); } self::$listeners[$yFnpO][] = $k3w31; } } public static function get($c6VKG = '') { if (empty($c6VKG)) { return self::$listeners; } return array_key_exists($c6VKG, self::$listeners) ? self::$listeners[$c6VKG] : array(); } public static function fire($c6VKG, &$pFM9U = null, $lVCis = null) { goto YAmyd; E_KSv: foreach (static::get($c6VKG) as $HQKqq => $k3w31) { $en0Zs[$HQKqq] = self::call($k3w31, $c6VKG, $pFM9U, $lVCis); } goto Vv4VJ; YAmyd: $en0Zs = array(); goto E_KSv; Vv4VJ: return $en0Zs; goto JDvHv; JDvHv: } public static function fireInView($c6VKG, &$pFM9U = null, $lVCis = null) { return join('', self::fire($c6VKG, $pFM9U, $lVCis)); } private static function call($k3w31, $c6VKG = '', &$pFM9U = null, $lVCis = null) { if ($k3w31 instanceof \Closure) { $LFzZs = call_user_func_array($k3w31, array(&$pFM9U, $lVCis)); } elseif (is_array($k3w31)) { list($k3w31, $hiFdg) = $k3w31; $LFzZs = call_user_func_array(array(&$k3w31, $hiFdg), array(&$pFM9U, $lVCis)); } else { if (is_object($k3w31)) { $hiFdg = "on{$c6VKG}"; $LFzZs = call_user_func_array(array(&$k3w31, $hiFdg), array(&$pFM9U, $lVCis)); } elseif (strpos($k3w31, '::')) { $LFzZs = call_user_func_array($k3w31, array(&$pFM9U, $lVCis)); } else { BizException::throws('ModStartHook call error'); } } return $LFzZs; } }