/
v.bolshakov
/
AIEcosystem-Testing
Обзор
Документация
Войти
/
v.bolshakov
/
AIEcosystem-Testing
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
CI/CD
Аналитика
Безопасность
dev
console/controllers/BaseController.php
72 строки
2 KB
Developer
Initial commit
03 авг 2026, 17:43
03 авг 2026, 17:43
7433917
Код
Авторство
О чём код?
<?php namespace console\controllers; use common\components\Connection; use common\helpers\DateHelper; use common\models\SystemTool; use Yii; use yii\console\Controller; use yii\helpers\Console; /** * Базовый консольный контроллер * * @author Dmitry E. Semenov <sde.tomsk@gmail.com> * @copyright Self (c) 2019-2026 */ abstract class BaseController extends Controller { /** * Время начала работы * @var null */ protected $start_at = null; /** * @var null */ protected $system_tool_id = null; /** * @inheritdoc */ public function beforeAction($action) { $this->start_at = microtime(true); $this->stdout('Start at: ' . DateHelper::now() . PHP_EOL, Console::FG_BLUE); /** @var Connection $db */ $db = Yii::$app->db; $db->pingRepeat(); if ($this->system_tool_id) { $tool = SystemTool::findOne($this->system_tool_id); if ($tool) { if (!$tool->is_active) { return false; } $tool->updateAttributes([ 'last_check' => DateHelper::now() ]); } } return parent::beforeAction($action); // TODO: Change the autogenerated stub } /** * @inheritdoc */ public function afterAction($action, $result) { $parent = parent::afterAction($action, $result); // TODO: Change the autogenerated stub $done = microtime(true) - $this->start_at; $this->stdout('Sync time: ' . sprintf('%.3f', $done) . PHP_EOL, Console::FG_GREEN); return $parent; } }