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; }
/** * Подготовка данных для шаблона * @return $this */ public function run() { if ($this->allowRegisterAsset) { ShopGlobalWidget::widget(['clientOptions' => $this->shopClientOptions]); } return parent::run(); }
/** * @return string */ protected function _run() { $this->width -= 2; if ($this->width > 0) { $this->imgWidth = round(($this->width - (17 + 9 * $this->inline)) / $this->inline); } if ($this->showBy == 'tag') { $this->isShowToolbar = false; } $instagram = \Yii::$app->instagramComponent; $instagram->setClientId($this->clientId); $instagram->setCount($this->count); if ($this->showBy == 'user') { $instagram->setUserName($this->userName); $this->user = $instagram->findUser(); $this->media = $instagram->findMediaByUser(); } elseif ($this->showBy == 'tag') { $instagram->setTag($this->tag); $this->media = $instagram->findMediaByTag(); } if (empty($this->userName)) { $this->userName = $instagram->userName; } $this->error_message = $instagram->error_message; return parent::_run(); }
protected function _run() { try { $form = null; if ($this->form_id) { $this->modelForm = Form2Form::find()->where(['id' => $this->form_id])->one(); if (!$this->modelForm) { throw new ErrorException("Форма не найдена: id=" . $this->form_id); } } else { if ($this->form_code) { $this->modelForm = Form2Form::find()->where(['code' => $this->form_code])->one(); if ($form) { $this->form_id = $form->id; } } if (!$this->modelForm) { throw new ErrorException("Форма не найдена: code=" . $this->form_code); } } } catch (\Exception $e) { \Yii::warning($e->getMessage(), static::className()); } if (!$this->modelForm) { return ""; } return parent::_run(); }
protected function _run() { $key = $this->getCacheKey() . 'run'; $dependency = new TagDependency(['tags' => [$this->className() . (string) $this->namespace, (new Tree())->getTableCacheTag()]]); $result = \Yii::$app->cache->get($key); if ($result === false || $this->enabledRunCache == Cms::BOOL_N) { $this->activeQuery = Tree::find(); if ($this->treePid) { $this->activeQuery->andWhere(['pid' => $this->treePid]); } if ($this->level) { $this->activeQuery->andWhere(['level' => $this->level]); } if ($this->active) { $this->activeQuery->andWhere(['active' => $this->active]); } if ($this->site_codes) { $this->activeQuery->andWhere(['site_code' => $this->site_codes]); } if ($this->enabledCurrentSite == Cms::BOOL_Y && ($currentSite = \Yii::$app->cms->site)) { $this->activeQuery->andWhere(['site_code' => $currentSite->code]); } if ($this->orderBy) { $this->activeQuery->orderBy([$this->orderBy => (int) $this->order]); } if ($this->tree_type_ids) { $this->activeQuery->andWhere(['tree_type_id' => $this->tree_type_ids]); } /** * */ if ($this->with) { $this->activeQuery->with($this->with); } if ($this->activeQueryCallback && is_callable($this->activeQueryCallback)) { $callback = $this->activeQueryCallback; $callback($this->activeQuery); } $result = parent::_run(); \Yii::$app->cache->set($key, $result, (int) $this->runCacheDuration, $dependency); } return $result; }
public static function descriptorConfig() { return array_merge(parent::descriptorConfig(), ['name' => \Yii::t('app', 'Breadcrumbs')]); }
protected function _run() { $cacheKey = $this->getCacheKey() . 'run'; $dependency = new TagDependency(['tags' => [$this->className() . (string) $this->namespace, (new CmsContentElement())->getTableCacheTag()]]); $result = \Yii::$app->cache->get($cacheKey); if ($result === false || $this->enabledRunCache == Cms::BOOL_N) { $this->initDataProvider(); if ($this->createdBy) { $this->dataProvider->query->andWhere([CmsContentElement::tableName() . '.created_by' => $this->createdBy]); } if ($this->active) { $this->dataProvider->query->andWhere([CmsContentElement::tableName() . '.active' => $this->active]); } if ($this->content_ids) { $this->dataProvider->query->andWhere([CmsContentElement::tableName() . '.content_id' => $this->content_ids]); } if ($this->limit) { $this->dataProvider->query->limit($this->limit); } $treeIds = (array) $this->tree_ids; if ($this->enabledCurrentTree == Cms::BOOL_Y) { $tree = \Yii::$app->cms->getCurrentTree(); if ($tree) { $treeIds[] = $tree->id; if ($tree->children && $this->enabledCurrentTreeChild == Cms::BOOL_Y) { if ($this->enabledCurrentTreeChildAll) { if ($childrens = $tree->children) { foreach ($childrens as $chidren) { $treeIds[] = $chidren->id; } } } else { if ($childrens = $tree->children) { foreach ($childrens as $chidren) { $treeIds[] = $chidren->id; } } } } } } if ($treeIds) { foreach ($treeIds as $key => $treeId) { if (!$treeId) { unset($treeIds[$key]); } } if ($treeIds) { /** * @var $query ActiveQuery */ $query = $this->dataProvider->query; $query->joinWith('cmsContentElementTrees'); $query->andWhere(['or', [CmsContentElement::tableName() . '.tree_id' => $treeIds], [CmsContentElementTree::tableName() . '.tree_id' => $treeIds]]); } } if ($this->enabledActiveTime == Cms::BOOL_Y) { $this->dataProvider->query->andWhere(["<=", CmsContentElement::tableName() . '.published_at', \Yii::$app->formatter->asTimestamp(time())]); $this->dataProvider->query->andWhere(['or', [">=", CmsContentElement::tableName() . '.published_to', \Yii::$app->formatter->asTimestamp(time())], [CmsContentElement::tableName() . '.published_to' => null]]); } /** * */ if ($this->with) { $this->dataProvider->query->with($this->with); } $this->dataProvider->query->groupBy([CmsContentElement::tableName() . '.id']); if ($this->activeQueryCallback && is_callable($this->activeQueryCallback)) { $callback = $this->activeQueryCallback; $callback($this->dataProvider->query); } if ($this->dataProviderCallback && is_callable($this->dataProviderCallback)) { $callback = $this->dataProviderCallback; $callback($this->dataProvider); } $result = parent::_run(); \Yii::$app->cache->set($cacheKey, $result, (int) $this->runCacheDuration, $dependency); } return $result; }
public function rules() { return ArrayHelper::merge(parent::rules(), [[['content_id'], 'integer'], [['searchModelAttributes'], 'safe'], [['realatedProperties'], 'safe'], [['type_price_id'], 'integer']]); }
/** * @return string */ protected function _run() { VkAsset::register($this->view); return parent::_run(); }
protected function _run() { $this->initDataProvider(); if ($this->createdBy) { $this->dataProvider->query->andWhere([Comments2Message::tableName() . '.created_by' => $this->createdBy]); } if ($this->site_codes) { $this->dataProvider->query->andWhere([Comments2Message::tableName() . '.site_code' => $this->site_codes]); } if ($this->statuses) { $this->dataProvider->query->andWhere([Comments2Message::tableName() . '.status' => $this->statuses]); } if ($this->cmsContentElement) { $this->dataProvider->query->andWhere([Comments2Message::tableName() . '.element_id' => $this->cmsContentElement->id]); } if ($this->limit) { $this->dataProvider->query->limit($this->limit); } $this->modelMessage = new Comments2Message(); return parent::_run(); }
protected function _run() { if ($this->elementIds && !$this->searchModel->price_from && $this->typePrice) { $this->searchModel->price_from = $this->minPrice->price; } if ($this->elementIds && !$this->searchModel->price_to && $this->typePrice) { $this->searchModel->price_to = $this->maxPrice->price; } return parent::_run(); }