3
0
Fork 0
This commit is contained in:
Александр Рыбкин 2021-04-26 17:23:35 +03:00
parent 19444853cf
commit 277ef0beb2
1 changed files with 10 additions and 1 deletions

View File

@ -126,6 +126,14 @@ class MoleTask extends \yii\db\ActiveRecord
*/
public static function add($controller, $name, $params = array(), $priority = 0, $period = 0, $dateAdd = false, $project = false)
{
$module = '';
if(stripos($model->controller, '.'))
{
$arController = explode('.', $controller);
$module = $arController[0];
$controller = $arController[1];
}
$model = new MoleTask();
$model->controller = $controller;
$model->name = $name;
@ -134,7 +142,8 @@ class MoleTask extends \yii\db\ActiveRecord
$model->period = $period;
$model->dateAdd = $dateAdd ?: date('Y-m-d H:i:s');
$model->project = $project ?: Yii::$app->getModule('cron')->project;
$model->type = stripos($model->controller, '.') ? $model->controller : ($model->project . '.' . $model->controller); // для совместимости
$model->module = $module;
$model->type = stripos($controller, '.') ? $controller : ($model->project . '.' . $model->controller); // для совместимости
return $model->save();
}