From 6913fbf534f7f5b9c50df88c4f9b9c08f927412c Mon Sep 17 00:00:00 2001 From: Sasha Rybkin Date: Mon, 26 Apr 2021 16:47:55 +0300 Subject: [PATCH] =?UTF-8?q?=D0=94=D0=BE=D0=B1=D0=B0=D0=B2=D0=BB=D0=B5?= =?UTF-8?q?=D0=BD=D0=B8=D0=B5=20=D1=87=D0=B5=D1=80=D0=B5=D0=B7=20=D0=BC?= =?UTF-8?q?=D0=BE=D0=B4=D1=83=D0=BB=D1=8C?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Module.php | 26 ++++++++++++++++++++++++++ models/MoleTask.php | 4 ++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/Module.php b/Module.php index 110e24b..ee225ed 100644 --- a/Module.php +++ b/Module.php @@ -4,6 +4,7 @@ namespace dominion\cron; use yii\base\BootstrapInterface; use yii\i18n\PhpMessageSource; +use dominion\cron\models\MoleTask; /** * cron module definition class @@ -45,5 +46,30 @@ class Module extends \yii\base\Module implements BootstrapInterface ]; } } + /** + * Добавление агента (обертка) + * @param string $controller + * @param string $name + * @param array $params + * @param int $priority + * @param int $period + * @param date $dateAdd + * @param string $project + * @return boolean + */ + public function add($controller, $name, $params = array(), $priority = 0, $period = 0, $dateAdd = false, $project = false) + { + return MoleTask::add($controller, $name, $params, $priority, $period, $dateAdd, $project); + } + + /** + * Выбираем все строки с project + */ + public function getAllTask($project = false) + { + $model = new MoleTask(); + return $model->getAllTask($project); + } + } diff --git a/models/MoleTask.php b/models/MoleTask.php index c66f121..2a50181 100644 --- a/models/MoleTask.php +++ b/models/MoleTask.php @@ -82,11 +82,11 @@ class MoleTask extends \yii\db\ActiveRecord /** * Выбираем все строки с project */ - public function getAllTask() + public function getAllTask($project = false) { return self::find() ->andWhere([ - 'project' => Yii::$app->getModule('cron')->project, + 'project' => $project ?: Yii::$app->getModule('cron')->project, 'completed' => 0, ]) ->andWhere(['IS', 'dateStart', NULL])