Exemplo n.º 1
0
 private function findArticleBySeoUrl($seoUrl, $categoryId, $options = [])
 {
     $articlesSeoData = SeoData::find()->where(['entity_name' => ArticleTranslation::className(), 'seo_url' => $seoUrl])->all();
     if ($articlesSeoData) {
         foreach ($articlesSeoData as $articleSeoData) {
             if ($article = Article::find()->joinWith('translations translation')->where(array_merge(['translation.id' => $articleSeoData->entity_id, 'category_id' => $categoryId, 'translation.language_id' => $this->currentLanguage->id], $options))->one()) {
                 return $article;
             }
         }
     }
     return null;
 }
Exemplo n.º 2
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getTranslations()
 {
     return $this->hasMany(ArticleTranslation::className(), ['article_id' => 'id']);
 }