40 lines
1.7 KiB
PHP
40 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace admin\components\UI;
|
|
|
|
/**
|
|
* 通用部件
|
|
* Class Composite
|
|
* @package backend\components\UI
|
|
* @method static \backend\components\UI\Widget\Alert alert(string $content, string $title = null, callable $callback = NULL)
|
|
* @method static \backend\components\UI\Widget\Badge badge($content, callable $callback = NULL)
|
|
* @method static \backend\components\UI\Widget\Images images($list, callable $callback = NULL)
|
|
* @method static \backend\components\UI\Widget\Form form($data, callable $callback = NULL)
|
|
* @method static \backend\components\UI\Widget\Icon icon($content, callable $callback = NULL)
|
|
* @method static \backend\components\UI\Widget\Link link($data, callable $callback = NULL)
|
|
* @method static \backend\components\UI\Widget\Menu menu(string $name, string $type = 'default', callable $callback = NULL)
|
|
* @method static \backend\components\UI\Widget\Table table($data, callable $callback = NULL)
|
|
* @method static \backend\components\UI\Widget\Text text($content, callable $callback = NULL)
|
|
* @method static \backend\components\UI\Widget\Row row(callable $callback = NULL)
|
|
* @method static \backend\components\UI\Widget\StatsCard statsCard(callable $callback = NULL)
|
|
*/
|
|
class Widget
|
|
{
|
|
|
|
private static $extend;
|
|
|
|
public static function __callStatic($method, $arguments)
|
|
{
|
|
$class = 'backend\\components\\UI\\Widget\\' . ucfirst($method);
|
|
if (!class_exists($class)) {
|
|
if (!self::$extend[$method]) {
|
|
throw new \RuntimeException('There is no widget method "' . $method . '"');
|
|
} else {
|
|
$class = self::$extend[$method];
|
|
}
|
|
}
|
|
$object = new $class(...$arguments);
|
|
return $object->next()->getRender();
|
|
}
|
|
}
|