<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Vendor\Provider; trait ProviderTrait { private static $list = array(); public static function register($oMd7I) { self::$list[] = $oMd7I; } public static function listAll() { goto fx5I3; M3qZn: if ($mKlmF) { return self::$list; } goto BEzrG; tSfLg: $mKlmF = true; goto rkNU9; tR154: foreach (self::$list as $kEhTf => $y2Ltn) { if ($y2Ltn instanceof \Closure) { self::$list[$kEhTf] = call_user_func($y2Ltn); } else { if (is_string($y2Ltn)) { self::$list[$kEhTf] = app($y2Ltn); } } if (!$aG9A9 && method_exists(self::$list[$kEhTf], 'order')) { $aG9A9 = true; } } goto Oc9q0; BEzrG: $aG9A9 = false; goto tR154; Oc9q0: if ($aG9A9) { @usort(self::$list, function ($x8QyM, $u5boX) { if ($x8QyM->order() == $u5boX->order()) { return 0; } return $x8QyM->order() > $u5boX->order() ? 1 : -1; }); } goto tSfLg; fx5I3: static $mKlmF = false; goto M3qZn; rkNU9: return self::$list; goto Q2WqD; Q2WqD: } public static function allMap() { return array_build(self::listAll(), function ($kEhTf, $y2Ltn) { return array($y2Ltn->name(), $y2Ltn->title()); }); } public static function allDefaultMap() { return array_merge(array('' => L('None')), array_build(self::listAll(), function ($kEhTf, $y2Ltn) { return array($y2Ltn->name(), $y2Ltn->title()); })); } public static function isEmpty() { return empty(self::$list); } public static function getByName($L1N0l) { foreach (self::listAll() as $jIWZA) { if ($jIWZA->name() == $L1N0l) { return $jIWZA; } } return null; } public static function first() { foreach (self::listAll() as $jIWZA) { return $jIWZA; } return null; } }