/** * Creates a new MetaBase model. * If creation is successful, the browser will be redirected to the 'view' page. * @return mixed */ public function actionCreate() { $model = new Meta(); if ($model->load(Yii::$app->request->post()) && $model->save()) { return $this->redirect(['view', 'id' => $model->id_meta]); } else { return $this->render('create', ['model' => $model]); } }
/** * @param string $route * @return array */ public function getMeta($route) { // $cache = Yii::$app->{$this->cache}; // $cacheId = $this->componentId . '|routes|' . $route . '|city|' . $this->city; // $aMeta = $cache->get($cacheId); // if ($aMeta) { // return $aMeta; // } $aMeta = []; $model = Meta::findOne(['hash' => md5($route)]); if (!empty($model)) { $info = $model->toArray(); foreach ($info as $idData => $data) { if (!empty($data)) { $aMeta[$idData] = $data; } } //находим альтернативный текст для города $aMeta = $this->replaceInfotext($aMeta); //TODO отключаем формирование ссылок в тексте по ключам $aMeta = $this->setLinks($aMeta, ['infotext_before', 'infotext_after']); } elseif (Yii::$app->request->get('seo') === 'add') { //при передаче гетом переменной seo = add страница добавиться в базу, только если ее там нет $oMeta = new Meta(); $oMeta->setRoute($route); $oMeta->save(); } // $oTagDependency = new \yii\caching\TagDependency(['tags' => self::CACHE_TAG]); // // $cache->set($cacheId, $aMeta, $this->cacheDuration, $oTagDependency); return $aMeta; }