/** * 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; $aMeta = $cache->get($cacheId); if ($aMeta) { return $aMeta; } $oMeta = new Meta(); $oMeta->setRoute($route); $aMeta = []; $model = Meta::findOne(['hash' => $oMeta->hash]); if (!empty($model)) { $info = $model->toArray(); foreach ($info as $idData => $data) { if (!empty($data)) { $aMeta[$idData] = $data; } } } else { // Si no existe la entrada con esa ruta la creamos $oMeta->save(); } $oTagDependency = new \yii\caching\TagDependency(['tags' => self::CACHE_TAG]); $cache->set($cacheId, $aMeta, $this->cacheDuration, $oTagDependency); return $aMeta; }