<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Hook; use ModStart\Core\Exception\BizException; class ModStartHook { private static $listeners = array(); public static function subscribe($L1g9F, $B1Qd6) { if (!is_array($L1g9F)) { $L1g9F = array($L1g9F); } foreach ($L1g9F as $nsWl0) { if (!isset(self::$listeners[$nsWl0])) { self::$listeners[$nsWl0] = array(); } self::$listeners[$nsWl0][] = $B1Qd6; } } public static function get($L1g9F = '') { if (empty($L1g9F)) { return self::$listeners; } return array_key_exists($L1g9F, self::$listeners) ? self::$listeners[$L1g9F] : array(); } public static function fire($L1g9F, &$zlK8N = null, $wZmAP = null) { goto fhkxH; fhkxH: $Lydiv = array(); goto yLrSR; KWM7H: return $Lydiv; goto t_gOq; yLrSR: foreach (static::get($L1g9F) as $rvTrU => $B1Qd6) { $Lydiv[$rvTrU] = self::call($B1Qd6, $L1g9F, $zlK8N, $wZmAP); } goto KWM7H; t_gOq: } public static function fireInView($L1g9F, &$zlK8N = null, $wZmAP = null) { return join('', self::fire($L1g9F, $zlK8N, $wZmAP)); } private static function call($B1Qd6, $L1g9F = '', &$zlK8N = null, $wZmAP = null) { if ($B1Qd6 instanceof \Closure) { $Iy3i6 = call_user_func_array($B1Qd6, array(&$zlK8N, $wZmAP)); } elseif (is_array($B1Qd6)) { list($B1Qd6, $HxDDI) = $B1Qd6; $Iy3i6 = call_user_func_array(array(&$B1Qd6, $HxDDI), array(&$zlK8N, $wZmAP)); } else { if (is_object($B1Qd6)) { $HxDDI = "on{$L1g9F}"; $Iy3i6 = call_user_func_array(array(&$B1Qd6, $HxDDI), array(&$zlK8N, $wZmAP)); } elseif (strpos($B1Qd6, '::')) { $Iy3i6 = call_user_func_array($B1Qd6, array(&$zlK8N, $wZmAP)); } else { BizException::throws('ModStartHook call error'); } } return $Iy3i6; } }