/** * 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; }
/** * 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; }