3
0
Fork 0

Добавление через модуль

This commit is contained in:
Александр Рыбкин 2021-04-26 16:47:55 +03:00
parent 923acb86f1
commit 6913fbf534
2 changed files with 28 additions and 2 deletions

View File

@ -4,6 +4,7 @@ namespace dominion\cron;
use yii\base\BootstrapInterface; use yii\base\BootstrapInterface;
use yii\i18n\PhpMessageSource; use yii\i18n\PhpMessageSource;
use dominion\cron\models\MoleTask;
/** /**
* cron module definition class * 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);
}
} }

View File

@ -82,11 +82,11 @@ class MoleTask extends \yii\db\ActiveRecord
/** /**
* Выбираем все строки с project * Выбираем все строки с project
*/ */
public function getAllTask() public function getAllTask($project = false)
{ {
return self::find() return self::find()
->andWhere([ ->andWhere([
'project' => Yii::$app->getModule('cron')->project, 'project' => $project ?: Yii::$app->getModule('cron')->project,
'completed' => 0, 'completed' => 0,
]) ])
->andWhere(['IS', 'dateStart', NULL]) ->andWhere(['IS', 'dateStart', NULL])