<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace Module\Vendor\Provider; trait ProviderTrait { private static $list = array(); public static function register($sefXk) { self::$list[] = $sefXk; } public static function listAll() { goto xFPQG; xFPQG: static $nlN8K = false; goto ske1Z; cDBTF: $QtlCl = false; goto Zx0YG; ske1Z: if ($nlN8K) { return self::$list; } goto cDBTF; PQnGN: $nlN8K = true; goto jWVqC; I8rqi: if ($QtlCl) { @usort(self::$list, function ($fRr3h, $gZCvG) { if ($fRr3h->order() == $gZCvG->order()) { return 0; } return $fRr3h->order() > $gZCvG->order() ? 1 : -1; }); } goto PQnGN; Zx0YG: foreach (self::$list as $JdFJR => $PSYn9) { if ($PSYn9 instanceof \Closure) { self::$list[$JdFJR] = call_user_func($PSYn9); } else { if (is_string($PSYn9)) { self::$list[$JdFJR] = app($PSYn9); } } if (!$QtlCl && method_exists(self::$list[$JdFJR], 'order')) { $QtlCl = true; } } goto I8rqi; jWVqC: return self::$list; goto Zm1he; Zm1he: } public static function allMap() { return array_build(self::listAll(), function ($JdFJR, $PSYn9) { return array($PSYn9->name(), $PSYn9->title()); }); } public static function allDefaultMap() { return array_merge(array('' => L('None')), array_build(self::listAll(), function ($JdFJR, $PSYn9) { return array($PSYn9->name(), $PSYn9->title()); })); } public static function isEmpty() { return empty(self::$list); } public static function getByName($BjHij) { foreach (self::listAll() as $vPOhn) { if ($vPOhn->name() == $BjHij) { return $vPOhn; } } return null; } public static function first() { foreach (self::listAll() as $vPOhn) { return $vPOhn; } return null; } }