/
v.bolshakov
/
AIEcosystem-Testing
Обзор
Документация
Войти
/
v.bolshakov
/
AIEcosystem-Testing
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
dev
common/widgets/ShowInfoWidget.php
100 строк
2 KB
Developer
Initial commit
03 авг 2026, 17:43
03 авг 2026, 17:43
7433917
Код
Авторство
О чём код?
<?php namespace common\widgets; use common\crud\ShowViewCrud; use Yii; use yii\base\InvalidCallException; use yii\web\NotFoundHttpException; /** * Виджет - Просмотр информации об объекте * * @author Dmitry E. Semenov <sde.tomsk@gmail.com> * @copyright Self (c) 2022 */ class ShowInfoWidget extends BasePanelWidget { /** * @inheritdoc */ public $title = 'Information'; /** * @inheritdoc */ public $viewName = 'info.twig'; /** * id Объекта, системную информацию о котором требуется вывести * @var integer * @see BaseModel */ public $oid = null; /** * class_name Объекта */ public $class_name = null; /** * Название таблицы * @var null */ public $table_name = null; /** * @inheritdoc */ public $icon = 'icon-info3'; /** * @inheritdoc */ public $panel_type = 'success'; /** * @inheritdoc */ protected function doRun() { $classname = $this->class_name; if ($classname) { $object = null; if (class_exists($classname)) { $object = $classname::findOne($this->oid); } if (!$object) { throw new NotFoundHttpException('Not found'); } if ($object->hasMethod('getTitle') or $object->hasAttribute('title')) { $title = $object->title; } else { $title = get_class($object); } $info = [ 'type' => 'info', 'list' => [ $object->modelName(0) => $title, ], ]; } else { throw new InvalidCallException(Yii::t('app', 'Class name required')); } $crud = new ShowViewCrud(); $crud->setModel($object); return [ 'model' => $object, 'crud' => $crud, 'info' => $info, ]; } }