コード例 #1
0
ファイル: Meta.php プロジェクト: flarmn/dotplant2
 public static function registrationMeta()
 {
     if (Yii::$app->request->isAjax === false && !BackendModule::isBackend()) {
         $cacheName = Yii::$app->getModule('seo')->cacheConfig['metaCache']['name'];
         $cacheExpire = Yii::$app->getModule('seo')->cacheConfig['metaCache']['expire'];
         $metas = Yii::$app->getCache()->get($cacheName);
         if ($metas === false) {
             $metas = Meta::find()->all();
             Yii::$app->getCache()->set($cacheName, $metas, $cacheExpire);
         }
         foreach ($metas as $meta) {
             Yii::$app->controller->getView()->registerMetaTag(['name' => $meta->name, 'content' => $meta->content], $meta->key);
         }
     }
 }