src/apis/CommonController.php
public function actionSchedulerAdd()
    {
        $model = new Scheduler();
        $model->attributes = Yii::$app->request->bodyParams;

        if (!$model->hasTriggerPermission($model->model_class)) {
            throw new ForbiddenHttpException("Unable to schedule a task for the given model.");
        }

        if ($model->save()) {
            $model->pushQueue();

            // if its a "now" job, run the internal worker now so the log table is refreshed immediately
            Yii::$app->adminqueue->run(false);
            Config::set(Config::CONFIG_QUEUE_TIMESTAMP, time());
            return $model;
        }

        return $this->sendModelError($model);
    }
public function actionSchedulerAdd()
    {
        $model = new Scheduler();
        $model->attributes = Yii::$app->request->bodyParams;

        if (!$model->hasTriggerPermission($model->model_class)) {
            throw new ForbiddenHttpException("Unable to schedule a task for the given model.");
        }

        if ($model->save()) {
            $model->pushQueue();

            // if its a "now" job, run the internal worker now so the log table is refreshed immediately
            Yii::$app->adminqueue->run(false);
            Config::set(Config::CONFIG_QUEUE_TIMESTAMP, time());
            return $model;
        }

        return $this->sendModelError($model);
    }
public function actionSchedulerAdd ( ) { $ model = new Scheduler ( ) ; $ model -> attributes = Yii :: $ app -> request -> bodyParams ; if ( ! $ model -> hasTriggerPermission ( $ model -> model_class ) ) { throw new ForbiddenHttpException ( "Unable to schedule a task for the given model." ) ; } if ( $ model -> save ( ) ) { $ model -> pushQueue ( ) ; // if its a "now" job, run the internal worker now so the log table is refreshed immediately Yii :: $ app -> adminqueue -> run ( false ) ; Config :: set ( Config :: CONFIG_QUEUE_TIMESTAMP , time ( ) ) ; return $ model ; } return $ this -> sendModelError ( $ model ) ; }
Add a task to the scheduler.

@return array
@since 2.0.0
Add a task to the scheduler .