Exemple #1
0
 public function save()
 {
     if (!$this->validate()) {
         return false;
     }
     if (!empty($this->id)) {
         $theme = MainTheme::findOne($this->id);
     }
     if (!isset($theme) || empty($theme)) {
         $theme = new MainTheme();
     }
     $theme->setAttributes(['name' => $this->name, 'color' => $this->color, 'order' => $this->order, 'enabled' => $this->enabled, 'titleWords' => $this->titleWords, 'textWords' => $this->textWords]);
     $theme->setCategories($this->categories);
     $theme->setArticles($this->articles);
     if ($theme->save(false)) {
         $this->id = $theme->id;
     }
     return !empty($this->id);
 }