Добавление через модуль
This commit is contained in:
parent
923acb86f1
commit
6913fbf534
26
Module.php
26
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);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
|
|
@ -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])
|
||||
|
|
Loading…
Reference in New Issue