/** * Before-save callback, used to strip tags from content. * * @return boolean False if parent beforeSave() failed, true otherwise. * @since 0.1.0 */ public function beforeSave() { if (!parent::beforeSave()) { return false; } return true; }
/** * Before-save callback. * * @return boolean Returns false if parent beforeSave() returns false, * otherwise returns true. * @since 0.1.0 */ public function beforeSave() { if (!parent::beforeSave()) { return false; } if (!empty($this->newPassword)) { $this->password = sha1($this->newPassword); } return true; }
/** * A callback for automating category counter updates, timestamps and * ownership assignment. * Tricky part about ownership is that model shouldn't know anything about * current user, but easiest way to automate things is by adding it here * and not in controller (actually, controller itself should not alter * data in any way too). Adding author ID in beforeSave also breaks * validation a little (user_id should be required on post creation). * * @return boolean False if parent beforeSave() failed, true otherwise. * @since 0.1.0 */ public function beforeSave() { if (!parent::beforeSave()) { return false; } if ($this->getIsNewRecord()) { // This is quite tricky. See PHPDoc. if (!isset($this->user_id)) { if (empty(\Yii::app()->user->id)) { throw new \RuntimeException('Couldn\'t determine user ID'); } $this->user_id = \Yii::app()->user->id; } } else { $this->oldCategory = $this->getCurrentCategory(); } return true; }