Inheritance: extends craft\BaseModel
Example #1
0
 public function saveDefaultSettings($locale)
 {
     $model = new Seomatic_SettingsModel();
     $model->locale = $locale;
     /* -- Append the locale.id if this isn't the main site language */
     if ($locale != craft()->language) {
         $suffix = " (" . $locale . ")";
         $model->siteSeoName .= $suffix;
         $model->siteSeoTitle .= $suffix;
         $model->siteSeoDescription .= $suffix;
         $model->siteSeoKeywords .= $suffix;
     }
     $record = new Seomatic_SettingsRecord();
     $record->setAttributes($model->getAttributes(), false);
     if ($record->save()) {
         // update id on model (for new records)
         $model->setAttribute('id', $record->getAttribute('id'));
         return true;
     } else {
         $model->addErrors($record->getErrors());
         return false;
     }
 }