Files
xk-api-yii/admin/components/UI/Widget/Alert.php
2024-09-19 11:32:39 +08:00

52 lines
1000 B
PHP

<?php
namespace admin\components\UI\Widget;
/**
* 警告信息
* @package backend\components\UI\Widget
*/
class Alert extends Widget
{
protected string $type = 'info';
private ?string $title;
private $content;
/**
* @param string|array $content
* @param string|null $title
* @param callable|null $callback
*/
public function __construct($content, string $title = null, callable $callback = NULL)
{
$this->title = $title;
$this->content = $content;
$this->callback = $callback;
}
/**
* 文本类型
* @param $name
* @return $this
*/
public function type($name): self
{
$this->type = $name;
return $this;
}
/**
* @return array
*/
public function render(): array
{
return [
'nodeName' => 'a-alert',
'title' => $this->title,
'type' => $this->type,
'child' => $this->content
];
}
}