<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Vendor\Provider; trait ProviderTrait { private static $list = array(); public static function register($tDnAb) { self::$list[] = $tDnAb; } public static function listAll() { goto q8K4C; q8K4C: static $kB6Vv = false; goto TUmgH; v64hx: $slWXe = false; goto mq3zo; TUmgH: if ($kB6Vv) { return self::$list; } goto v64hx; bteVU: return self::$list; goto QGQlT; EoM33: if ($slWXe) { @usort(self::$list, function ($w9doT, $WJhGN) { if ($w9doT->order() == $WJhGN->order()) { return 0; } return $w9doT->order() > $WJhGN->order() ? 1 : -1; }); } goto POBcF; mq3zo: foreach (self::$list as $KAKiA => $Iim2u) { if ($Iim2u instanceof \Closure) { self::$list[$KAKiA] = call_user_func($Iim2u); } else { if (is_string($Iim2u)) { self::$list[$KAKiA] = app($Iim2u); } } if (!$slWXe && method_exists(self::$list[$KAKiA], 'order')) { $slWXe = true; } } goto EoM33; POBcF: $kB6Vv = true; goto bteVU; QGQlT: } public static function allMap() { return array_build(self::listAll(), function ($KAKiA, $Iim2u) { return array($Iim2u->name(), $Iim2u->title()); }); } public static function allDefaultMap() { return array_merge(array('' => L('None')), array_build(self::listAll(), function ($KAKiA, $Iim2u) { return array($Iim2u->name(), $Iim2u->title()); })); } public static function isEmpty() { return empty(self::$list); } public static function getByName($zO6V5) { foreach (self::listAll() as $YaV4m) { if ($YaV4m->name() == $zO6V5) { return $YaV4m; } } return null; } public static function first() { foreach (self::listAll() as $YaV4m) { return $YaV4m; } return null; } }