コード例 #1
0
ファイル: SitesCmsWidget.php プロジェクト: skeeks-cms/cms
 protected function _run()
 {
     $key = $this->getCacheKey() . 'run';
     $dependency = new TagDependency(['tags' => [$this->className() . (string) $this->namespace, (new CmsSite())->getTableCacheTag()]]);
     $result = \Yii::$app->cache->get($key);
     if ($result === false || $this->enabledRunCache == Cms::BOOL_N) {
         $this->activeQuery = CmsSite::find();
         if ($this->active == Cms::BOOL_Y) {
             $this->activeQuery->active();
         } else {
             if ($this->active == Cms::BOOL_N) {
                 $this->activeQuery->active(false);
             }
         }
         if ($this->limit) {
             $this->activeQuery->limit($limit);
         }
         if ($this->orderBy) {
             $this->activeQuery->orderBy([$this->orderBy => (int) $this->order]);
         }
         $result = parent::_run();
         \Yii::$app->cache->set($key, $result, (int) $this->runCacheDuration, $dependency);
     }
     return $result;
 }