/** * Runs the action * * @return string result content */ public function run($id) { $model = SchedulerTask::findOne($id); $request = Yii::$app->getRequest(); if (!$model) { throw new \yii\web\HttpException(404, 'The requested page does not exist.'); } if ($model->load($request->post())) { $model->save(); } $logModel = new SchedulerLog(); $logModel->scheduler_task_id = $model->id; $logDataProvider = $logModel->search($_GET); return $this->controller->render($this->view ?: $this->id, ['model' => $model, 'logModel' => $logModel, 'logDataProvider' => $logDataProvider]); }
/** * Runs the action * * @return string result content */ public function run($id) { $model = SchedulerLog::findOne($id); if (!$model) { throw new \yii\web\HttpException(404, 'The requested page does not exist.'); } return $this->controller->render($this->view ?: $this->id, ['model' => $model]); }
/** * Removes any records of tasks that no longer exist. * * @param Task[] $tasks */ public function cleanTasks($tasks) { $currentTasks = ArrayHelper::map($tasks, function ($task) { return $task->getName(); }, 'description'); foreach (SchedulerTask::find()->indexBy('name')->all() as $name => $task) { /* @var SchedulerTask $task */ if (!array_key_exists($name, $currentTasks)) { SchedulerLog::deleteAll(['scheduler_task_id' => $task->id]); $task->delete(); } } }
/** * @return \yii\db\ActiveQuery */ public function getSchedulerLogs() { return $this->hasMany(\webtoolsnz\scheduler\models\SchedulerLog::className(), ['scheduled_task_id' => 'id']); }