private function _checkRoute() { $route = Yii::$app->request->getPathInfo(); /** @var Module $module */ $module = Yii::$app->getModule('seomanager'); if ($module->cache) { $cacheKey = 'seomanager.route' . $route; $this->seoPage = Yii::$app->cache->get($cacheKey); if ($this->seoPage === false) { $this->seoPage = Seomanager::findOne(['route' => $route]); if ($this->seoPage === null) { // for routes that doesn´t add to the seomanger $cacheKey = 'seomanager.route.notfound'; } Yii::$app->cache->set($cacheKey, $this->seoPage, 300); } } else { $this->seoPage = Seomanager::findOne(['route' => $route]); } if ($this->seoPage !== null) { $module->seoPage = $this->seoPage; return true; } return false; }
private function _checkRoute() { $route = Yii::$app->request->getPathInfo(); $this->seoPage = Seomanager::findOne(['route' => $route]); if ($this->seoPage !== null) { return true; } return false; }
/** * Creates data provider instance with search query applied * * @param array $params * * @return ActiveDataProvider */ public function search($params) { $query = Seomanager::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, 'updated' => $this->updated, 'created' => $this->created]); $query->andFilterWhere(['like', 'route', $this->route])->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'keywords', $this->keywords])->andFilterWhere(['like', 'description', $this->description])->andFilterWhere(['like', 'canonical', $this->canonical])->andFilterWhere(['like', 'data', $this->data]); return $dataProvider; }
public function actionClearCache($id) { $model = Seomanager::findOne($id); if ($model !== null) { $key = 'seomanager.route' . $model->route; Yii::$app->cache->delete($key); } return $this->redirect(['update', 'id' => $id]); }
/** * Finds the Seo model based on its primary key value. * If the model is not found, a 404 HTTP exception will be thrown. * @param integer $id * @return Seo the loaded model * @throws NotFoundHttpException if the model cannot be found */ protected function findModel($id) { if (($model = Seomanager::findOne($id)) !== null) { return $model; } else { throw new NotFoundHttpException('The requested page does not exist.'); } }