Example #1
0
 /**
  * Check pathes
  * @param integer $limit 
  */
 public static function checkPathes($limit = 0)
 {
     $module = \Yii::$app->getModule('articles');
     $count = Category::find()->count();
     if ($count < 1) {
         $category = new Category();
         $category->title = $module->title;
         $category->name = $module->id;
         $category->genPath();
         $category->makeRoot();
         \Yii::$app->settings->set('articles.root', $category->id);
     }
     $categories = Category::find()->where(['path' => NULL])->all();
     foreach ($categories as $category) {
         $category->scenario = 'check';
         $category->save();
     }
     $articles = Article::find()->where(['path' => NULL])->all();
     foreach ($articles as $article) {
         $article->save();
     }
 }