<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Hook; use ModStart\Core\Exception\BizException; class ModStartHook { private static $listeners = array(); public static function subscribe($XggBq, $hca7g) { if (!is_array($XggBq)) { $XggBq = array($XggBq); } foreach ($XggBq as $V563N) { if (!isset(self::$listeners[$V563N])) { self::$listeners[$V563N] = array(); } self::$listeners[$V563N][] = $hca7g; } } public static function get($XggBq = '') { if (empty($XggBq)) { return self::$listeners; } return array_key_exists($XggBq, self::$listeners) ? self::$listeners[$XggBq] : array(); } public static function fire($XggBq, &$pmJAc = null, $jvx5O = null) { goto t8Lw8; t8Lw8: $WZJqt = array(); goto pOPd4; SIsTT: return $WZJqt; goto Kbt4G; pOPd4: foreach (static::get($XggBq) as $GUcFO => $hca7g) { $WZJqt[$GUcFO] = self::call($hca7g, $XggBq, $pmJAc, $jvx5O); } goto SIsTT; Kbt4G: } public static function fireInView($XggBq, &$pmJAc = null, $jvx5O = null) { return join('', self::fire($XggBq, $pmJAc, $jvx5O)); } private static function call($hca7g, $XggBq = '', &$pmJAc = null, $jvx5O = null) { if ($hca7g instanceof \Closure) { $XPCCC = call_user_func_array($hca7g, array(&$pmJAc, $jvx5O)); } elseif (is_array($hca7g)) { list($hca7g, $eNE35) = $hca7g; $XPCCC = call_user_func_array(array(&$hca7g, $eNE35), array(&$pmJAc, $jvx5O)); } else { if (is_object($hca7g)) { $eNE35 = "on{$XggBq}"; $XPCCC = call_user_func_array(array(&$hca7g, $eNE35), array(&$pmJAc, $jvx5O)); } elseif (strpos($hca7g, '::')) { $XPCCC = call_user_func_array($hca7g, array(&$pmJAc, $jvx5O)); } else { BizException::throws('ModStartHook call error'); } } return $XPCCC; } }