Example #1
0
 /**
  * Method in which can do some operations before saving to database.
  *
  * @access   protected
  * @param    Form $form
  * @since    1.0.0-alpha
  * @version  1.0.0-alpha
  */
 protected function beforeSave(Form &$form)
 {
     if ($this->getModel()->hasLocales()) {
         $aDoNotSaveFor = array_diff(Core::getLanguages(), $form->getCheckedLanguages());
         foreach ($aDoNotSaveFor as $sLang) {
             $this->getModel()->removeLocales($sLang);
         }
     }
     if (property_exists($this->getModel(), 'author') && !$this->getModel()->getAuthor() instanceof User) {
         $this->getModel()->setAuthor(User::getLoggedUser());
     }
     if (property_exists($this->getModel(), 'modification_date')) {
         $this->getModel()->updateModificationDate();
     }
 }