Example #1
0
 public function apply()
 {
     $this->_page->setAttributes($this->getAttributes(['pattern', 'title', 'keywords', 'description']), false);
     $this->_page->ogTags = Json::encode($this->ogTags);
     $result = $this->_page->save(false);
     Page::getPatterns(true);
     return $result;
 }
Example #2
0
 public static function getPatterns($refresh = false)
 {
     if (!isset(self::$_patterns) || $refresh) {
         if (!$refresh) {
             self::$_patterns = Yii::$app->cache->get('seoPatterns');
         }
         if (!self::$_patterns) {
             self::$_patterns = [];
             // TODO: Optimization
             /** @var Page[] $pages */
             $patterns = Page::find()->column('pattern');
             foreach ($patterns as $pattern) {
                 if (strpos($pattern, '*') !== false) {
                     self::$_patterns[$pattern] = '#^' . strtr($pattern, ['*' => '(.*)']) . '$#';
                 }
             }
             Yii::$app->cache->set('seoPatterns', self::$_patterns);
         }
     }
     return self::$_patterns;
 }
 public function beginPage(Event $event)
 {
     if (self::$_seoPage) {
         self::$_seoPage->registerMeta($this->owner);
     }
 }