Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = BatchJob::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'enabled' => $this->enabled]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'execution_time_configuration', $this->execution_time_configuration])->andFilterWhere(['like', 'command', $this->command]);
     return $dataProvider;
 }
 /**
  * Finds the BatchJob model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return BatchJob the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = BatchJob::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
Ejemplo n.º 3
0
 /**
  * Getting tasklist.
  *
  * @return array List of command actions associated with {@link PHPDocCrontab} runner.
  */
 protected function prepareActions()
 {
     $methods = [];
     $batchJobs = BatchJob::find()->where(['enabled' => true])->all();
     foreach ($batchJobs as $batchJob) {
         $methods = [$batchJob->command => ['cron' => $batchJob->execution_time_configuration]];
     }
     $actions = array();
     if (!empty($methods)) {
         foreach ($methods as $runCommand => $runSettings) {
             $runCommand = explode('/', $runCommand);
             if (count($runCommand) == 2) {
                 $actions[] = array('command' => $runCommand[0], 'action' => $runCommand[1], 'docs' => $this->parseDocComment($this->arrayToDocComment($runSettings)));
             }
             if (count($runCommand) == 3) {
                 $actions[] = array('command' => $runCommand[0] . '/' . $runCommand[1], 'action' => $runCommand[2], 'docs' => $this->parseDocComment($this->arrayToDocComment($runSettings)));
             }
             if (empty($actions)) {
                 continue;
             }
         }
     }
     return $actions;
 }
Ejemplo n.º 4
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getBatchJob()
 {
     return $this->hasOne(BatchJob::className(), ['id' => 'batch_job']);
 }