<?php
/**
 * ------------------------ 
 *  版权所有  www.tecmz.com
 *  商业版本请购买正版授权使用
 * ------------------------
*/ namespace ModStart\Support\Manager; class WidgetManager { private static $availableWidgets = array(); private static $collectedAssets = null; private static $usedWidgets = array(); public static function registerBuiltinWidgets() { $SRxBF = array('statusText' => \ModStart\Widget\StatusText::class, 'textAjaxRequest' => \ModStart\Widget\TextAjaxRequest::class, 'textDialogRequest' => \ModStart\Widget\TextDialogRequest::class, 'textAction' => \ModStart\Widget\TextAction::class, 'textLink' => \ModStart\Widget\TextLink::class, 'buttonAjaxRequest' => \ModStart\Widget\ButtonAjaxRequest::class, 'buttonDialogRequest' => \ModStart\Widget\ButtonDialogRequest::class); foreach ($SRxBF as $y8hHt => $KrsM3) { WidgetManager::extend($y8hHt, $KrsM3); } } public static function collectWidgetAssets($bOB5d = 'js|css|script|style') { goto pSF9A; VhHEi: static::$collectedAssets[$bOB5d] = $lR8is->flatten()->unique()->filter()->toArray(); goto vFiZT; vFiZT: return static::$collectedAssets[$bOB5d]; goto nNDsN; uzNi9: $lR8is = collect(); goto ZbN7B; pSF9A: if (!in_array($bOB5d, array('js', 'css', 'script', 'style'))) { return array(); } goto po5Aq; ZbN7B: foreach (static::$availableWidgets as $rPkIY => $SQ6_6) { goto mNQ_Q; VQU7Y: if (!method_exists($SQ6_6, 'getAssets')) { continue; } goto b_K0J; b_K0J: $lR8is->push(array_get(call_user_func(array($SQ6_6, 'getAssets')), $bOB5d)); goto HqVq9; mNQ_Q: if (in_array($bOB5d, array('js', 'script'))) { if (empty(static::$usedWidgets[$rPkIY])) { continue; } } goto VQU7Y; HqVq9: } goto VhHEi; po5Aq: if (isset(static::$collectedAssets[$bOB5d])) { return static::$collectedAssets[$bOB5d]; } goto uzNi9; nNDsN: } public static function extend($SQ6_6, $KrsM3) { static::$availableWidgets[$SQ6_6] = $KrsM3; } public static function findWidgetClass($JHYOH) { goto SNLCZ; MpKAG: if (class_exists($KrsM3)) { return $KrsM3; } goto NDv7d; SNLCZ: $KrsM3 = array_get(static::$availableWidgets, $JHYOH); goto MpKAG; NDv7d: return false; goto DlYYB; DlYYB: } public static function call($Ds7Jy, $JHYOH, $HPXJC) { if ($rgLyo = static::findWidgetClass($JHYOH)) { goto GvbRp; Cufb1: $gnky8 = array_get($HPXJC, 0, ''); goto r6xEf; r6xEf: $wi2ea = new $rgLyo($gnky8, array_slice($HPXJC, 1)); goto LOuwv; GvbRp: static::$usedWidgets[$JHYOH] = true; goto Cufb1; bc2PX: return $wi2ea; goto bRAU3; LOuwv: $Ds7Jy->pushField($wi2ea); goto bc2PX; bRAU3: } throw new \Exception('Widget [' . ucfirst($JHYOH) . '] not exists or registered, available: ' . json_encode(array_keys(static::$availableWidgets))); } }