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])