<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Hook; use ModStart\Core\Exception\BizException; class ModStartHook { private static $listeners = array(); public static function subscribe($f0dxO, $ECu1Z) { if (!is_array($f0dxO)) { $f0dxO = array($f0dxO); } foreach ($f0dxO as $OV1o4) { if (!isset(self::$listeners[$OV1o4])) { self::$listeners[$OV1o4] = array(); } self::$listeners[$OV1o4][] = $ECu1Z; } } public static function get($f0dxO = '') { if (empty($f0dxO)) { return self::$listeners; } return array_key_exists($f0dxO, self::$listeners) ? self::$listeners[$f0dxO] : array(); } public static function fire($f0dxO, &$AXgEz = null, $BepDp = null) { goto bURka; bURka: $SEvvy = array(); goto jtClH; DpWoM: return $SEvvy; goto Mgyka; jtClH: foreach (static::get($f0dxO) as $VFU9l => $ECu1Z) { $SEvvy[$VFU9l] = self::call($ECu1Z, $f0dxO, $AXgEz, $BepDp); } goto DpWoM; Mgyka: } public static function fireInView($f0dxO, &$AXgEz = null, $BepDp = null) { return join('', self::fire($f0dxO, $AXgEz, $BepDp)); } private static function call($ECu1Z, $f0dxO = '', &$AXgEz = null, $BepDp = null) { if ($ECu1Z instanceof \Closure) { $GlTLE = call_user_func_array($ECu1Z, array(&$AXgEz, $BepDp)); } elseif (is_array($ECu1Z)) { list($ECu1Z, $fVu6a) = $ECu1Z; $GlTLE = call_user_func_array(array(&$ECu1Z, $fVu6a), array(&$AXgEz, $BepDp)); } else { if (is_object($ECu1Z)) { $fVu6a = "on{$f0dxO}"; $GlTLE = call_user_func_array(array(&$ECu1Z, $fVu6a), array(&$AXgEz, $BepDp)); } elseif (strpos($ECu1Z, '::')) { $GlTLE = call_user_func_array($ECu1Z, array(&$AXgEz, $BepDp)); } else { BizException::throws('ModStartHook call error'); } } return $GlTLE; } }