/
v.bolshakov
/
AIEcosystem-Testing
Обзор
Документация
Войти
/
v.bolshakov
/
AIEcosystem-Testing
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
dev
backend/controllers/select/CommonController.php
77 строк
2 KB
Developer
Initial commit
03 авг 2026, 17:43
03 авг 2026, 17:43
7433917
Код
Авторство
О чём код?
<?php namespace backend\controllers\select; use common\controllers\base\DataController; use common\helpers\LanguageHelper; use common\helpers\NumHelper; use common\kdf\KLanguage; use common\traits\Select2Trait; use Yii; use yii\base\Model; /** * Общие списки * * @author Dmitry E. Semenov <sde.tomsk@gmail.com> * @copyright Self (c) 2021 */ class CommonController extends DataController { use Select2Trait; /** * Фильтр по статусу выполнения задачи */ public function actionStatus() { $this->model = new Model(); $this->query = [ ['id' => 1, 'name' => Yii::t('app', 'Active')], ['id' => 2, 'name' => Yii::t('app', 'Inactive')], ]; $this->format_callback = function ($id, $title, $model) { return [ $id => $model['id'], $title => Yii::t('app', $model['name']) ]; }; } /** * Фильтр по статусу выполнения задачи */ public function actionHour() { $hours = []; for ($i = 0; $i < 23; $i++) { $hours[] = ['id' => $i, 'name' => NumHelper::zero($i) . ':00 UTC']; } $this->model = new Model(); $this->query = $hours; $this->format_callback = function ($id, $title, $model) { return [ $id => $model['id'], $title => Yii::t('app', $model['name']) ]; }; } /** * Вывод списка языков для Select2 * * @throws \yii\base\InvalidConfigException */ public function actionLanguage() { $ids = array_keys(LanguageHelper::getLanguageList(KLanguage::ENGLISH)); $this->model = new KLanguage(); $this->query = KLanguage::find() ->andWhere(['id' => $ids]); } }