Ejemplo n.º 1
0
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Version::find();
     $dataProvider = new ActiveDataProvider(['query' => $query]);
     if (!($this->load($params) && $this->validate())) {
         return $dataProvider;
     }
     if ($this->created_at) {
         $query->andWhere('{{%grom_version}}.created_at >= :timestamp', ['timestamp' => $this->created_at]);
     }
     $query->andFilterWhere(['{{%grom_version}}.id' => $this->id, '{{%grom_version}}.item_id' => $this->item_id, '{{%grom_version}}.character_count' => $this->character_count, '{{%grom_version}}.created_by' => $this->created_by]);
     $query->andFilterWhere(['like', '{{%grom_version}}.item_class', $this->item_class])->andFilterWhere(['like', '{{%grom_version}}.version_note', $this->version_note])->andFilterWhere(['like', '{{%grom_version}}.version_hash', $this->version_hash])->andFilterWhere(['like', '{{%grom_version}}.version_data', $this->version_data])->andFilterWhere(['like', '{{%grom_version}}.keep_forever', $this->keep_forever]);
     return $dataProvider;
 }
Ejemplo n.º 2
0
 /**
  * @param $version_id integer
  * @return bool
  */
 public function checkout($version_id)
 {
     /** @var Version $version */
     $version = Version::find(['id' => $version_id, 'item_id' => $this->owner->getPrimaryKey(), 'item_class' => $this->owner->className()]);
     if ($version->restore()) {
         $this->owner->refresh();
         return true;
     }
     return false;
 }
Ejemplo n.º 3
0
 /**
  * Finds the Version model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Version the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Version::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }