<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Hook; use ModStart\Core\Exception\BizException; class ModStartHook { private static $listeners = array(); public static function subscribe($rPkIY, $aFa6d) { if (!is_array($rPkIY)) { $rPkIY = array($rPkIY); } foreach ($rPkIY as $El_MH) { if (!isset(self::$listeners[$El_MH])) { self::$listeners[$El_MH] = array(); } self::$listeners[$El_MH][] = $aFa6d; } } public static function get($rPkIY = '') { if (empty($rPkIY)) { return self::$listeners; } return array_key_exists($rPkIY, self::$listeners) ? self::$listeners[$rPkIY] : array(); } public static function fire($rPkIY, &$Kp99R = null, $VfUJ_ = null) { goto znSJv; ANsZa: foreach (static::get($rPkIY) as $ax5t3 => $aFa6d) { $DjVjC[$ax5t3] = self::call($aFa6d, $rPkIY, $Kp99R, $VfUJ_); } goto dHtau; dHtau: return $DjVjC; goto gC9oq; znSJv: $DjVjC = array(); goto ANsZa; gC9oq: } public static function fireInView($rPkIY, &$Kp99R = null, $VfUJ_ = null) { return join('', self::fire($rPkIY, $Kp99R, $VfUJ_)); } private static function call($aFa6d, $rPkIY = '', &$Kp99R = null, $VfUJ_ = null) { if ($aFa6d instanceof \Closure) { $ScTxp = call_user_func_array($aFa6d, array(&$Kp99R, $VfUJ_)); } elseif (is_array($aFa6d)) { list($aFa6d, $JHYOH) = $aFa6d; $ScTxp = call_user_func_array(array(&$aFa6d, $JHYOH), array(&$Kp99R, $VfUJ_)); } else { if (is_object($aFa6d)) { $JHYOH = "on{$rPkIY}"; $ScTxp = call_user_func_array(array(&$aFa6d, $JHYOH), array(&$Kp99R, $VfUJ_)); } elseif (strpos($aFa6d, '::')) { $ScTxp = call_user_func_array($aFa6d, array(&$Kp99R, $VfUJ_)); } else { BizException::throws('ModStartHook call error'); } } return $ScTxp; } }