public function parseRequest($manager, $request) { $pathInfo = $request->getPathInfo(); $pathInfo = chop($pathInfo, $manager->suffix); if (preg_match('%^([\\-\\w]+)?$%', $pathInfo, $matches) && $pathInfo != '') { $model = Page::findOne(['slug' => $matches[1]]); if ($model !== null) { $_GET['id'] = $model->id; return ["fluent/page/view", []]; } return false; } return false; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Page::find(); // add conditions that should always apply here $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; } // grid filtering conditions $query->andFilterWhere(['id' => $this->id, 'source_id' => -1]); $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'slug', $this->slug])->andFilterWhere(['like', 'content', $this->content]); return $dataProvider; }
/** * @inheritdoc */ public function down() { $this->dropColumn(Page::tableName(), 'source_id'); $this->dropColumn(Page::tableName(), 'lang_id'); }
public function actionView($id) { $page = Page::findOne($id)->getTranslation(Language::getCurrentLangID(), false); return $this->render('view', ['page' => $page]); }
public function down() { $this->dropTable(Page::tableName()); }
/** * Finds the Page model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Page the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Page::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }