<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Core\Provider; trait ProviderTrait { public static function register($gzdnL) { self::$list[] = $gzdnL; } public static function listAll() { goto uDxOW; DPdJI: return self::$list; goto z4pdd; GSlg2: if ($bqxP4) { @usort(self::$list, function ($gS0wE, $AzKjp) { if ($gS0wE->order() == $AzKjp->order()) { return 0; } return $gS0wE->order() > $AzKjp->order() ? 1 : -1; }); } goto oV3Rs; uDxOW: static $vcHad = false; goto r9WWg; r9WWg: if ($vcHad) { return self::$list; } goto vTMRY; vTMRY: $bqxP4 = false; goto kg6NU; kg6NU: foreach (self::$list as $GBNIv => $VFelt) { if ($VFelt instanceof \Closure) { self::$list[$GBNIv] = call_user_func($VFelt); } else { if (is_string($VFelt)) { self::$list[$GBNIv] = app($VFelt); } } if (!$bqxP4 && method_exists(self::$list[$GBNIv], 'order')) { $bqxP4 = true; } } goto GSlg2; oV3Rs: $vcHad = true; goto DPdJI; z4pdd: } public static function allMap() { return array_build(self::listAll(), function ($GBNIv, $VFelt) { return array($VFelt->name(), $VFelt->title()); }); } public static function allDefaultMap() { return array_merge(array('' => L('None')), array_build(self::listAll(), function ($GBNIv, $VFelt) { return array($VFelt->name(), $VFelt->title()); })); } public static function isEmpty() { return empty(self::$list); } public static function getByName($L1g9F) { foreach (self::listAll() as $nsWl0) { if ($nsWl0->name() == $L1g9F) { return $nsWl0; } } return null; } public static function first() { foreach (self::listAll() as $nsWl0) { return $nsWl0; } return null; } }