<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Provider; trait ProviderTrait { public static function register($QsTug) { self::$list[] = $QsTug; } public static function listAll() { goto G2YaG; SzCxY: $j4GRK = true; goto bpl4Q; iGxUA: if ($j4GRK) { return self::$list; } goto y1Ib0; G2YaG: static $j4GRK = false; goto iGxUA; nTTZc: foreach (self::$list as $RTHJ6 => $F6Fus) { if ($F6Fus instanceof \Closure) { self::$list[$RTHJ6] = call_user_func($F6Fus); } else { if (is_string($F6Fus)) { self::$list[$RTHJ6] = app($F6Fus); } } if (!$SPKEI && method_exists(self::$list[$RTHJ6], 'order')) { $SPKEI = true; } } goto V2yXy; V2yXy: if ($SPKEI) { @usort(self::$list, function ($Gc0Ve, $BtlHS) { if ($Gc0Ve->order() == $BtlHS->order()) { return 0; } return $Gc0Ve->order() > $BtlHS->order() ? 1 : -1; }); } goto SzCxY; bpl4Q: return self::$list; goto fxHL7; y1Ib0: $SPKEI = false; goto nTTZc; fxHL7: } public static function allMap() { return array_build(self::listAll(), function ($RTHJ6, $F6Fus) { return array($F6Fus->name(), $F6Fus->title()); }); } public static function allDefaultMap() { return array_merge(array('' => L('None')), array_build(self::listAll(), function ($RTHJ6, $F6Fus) { return array($F6Fus->name(), $F6Fus->title()); })); } public static function isEmpty() { return empty(self::$list); } public static function getByName($sQIr6) { foreach (self::listAll() as $Xvngd) { if ($Xvngd->name() == $sQIr6) { return $Xvngd; } } return null; } public static function first() { foreach (self::listAll() as $Xvngd) { return $Xvngd; } return null; } }