<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Hook; use ModStart\Core\Exception\BizException; class ModStartHook { private static $listeners = array(); public static function subscribe($sQIr6, $o7lk1) { if (!is_array($sQIr6)) { $sQIr6 = array($sQIr6); } foreach ($sQIr6 as $Xvngd) { if (!isset(self::$listeners[$Xvngd])) { self::$listeners[$Xvngd] = array(); } self::$listeners[$Xvngd][] = $o7lk1; } } public static function get($sQIr6 = '') { if (empty($sQIr6)) { return self::$listeners; } return array_key_exists($sQIr6, self::$listeners) ? self::$listeners[$sQIr6] : array(); } public static function fire($sQIr6, &$qHLCM = null, $SonpU = null) { goto i4MHj; i4MHj: $ui8L2 = array(); goto UBtxQ; SkxBJ: return $ui8L2; goto rgJkC; UBtxQ: foreach (static::get($sQIr6) as $jPfeB => $o7lk1) { $ui8L2[$jPfeB] = self::call($o7lk1, $sQIr6, $qHLCM, $SonpU); } goto SkxBJ; rgJkC: } public static function fireInView($sQIr6, &$qHLCM = null, $SonpU = null) { return join('', self::fire($sQIr6, $qHLCM, $SonpU)); } private static function call($o7lk1, $sQIr6 = '', &$qHLCM = null, $SonpU = null) { if ($o7lk1 instanceof \Closure) { $trLLJ = call_user_func_array($o7lk1, array(&$qHLCM, $SonpU)); } elseif (is_array($o7lk1)) { list($o7lk1, $fSCUf) = $o7lk1; $trLLJ = call_user_func_array(array(&$o7lk1, $fSCUf), array(&$qHLCM, $SonpU)); } else { if (is_object($o7lk1)) { $fSCUf = "on{$sQIr6}"; $trLLJ = call_user_func_array(array(&$o7lk1, $fSCUf), array(&$qHLCM, $SonpU)); } elseif (strpos($o7lk1, '::')) { $trLLJ = call_user_func_array($o7lk1, array(&$qHLCM, $SonpU)); } else { BizException::throws('ModStartHook call error'); } } return $trLLJ; } }