public function beforeValidation() { $validation = new Validation(); $validation->add('password', new Confirmation(array('message' => 'Password doesn\'t match confirmation', 'with' => 'retype_password'))); $validation->validate(['password' => $this->password, 'retype_password' => $this->retype_password]); $this->addMessages($validation->getMessages()); if (!empty($this->getMessages())) { return false; } if ($this->reg_date === null) { $this->reg_date = $this->timeService()->currentDateTime(); } if ($this->role === null) { $this->role = self::ROLE_USER; } if ($this->status === null) { $this->status = self::STATUS_NEW; } if ($this->rating === null) { $this->rating = (int) $this->rating; } if ($this->password !== null) { $this->password_hash = $this->createPasswordHash(); } return parent::beforeValidation(); }
public function beforeValidation() { if ($this->user_id === null) { $this->user_id = $this->user()->getID(); } if ($this->type === null) { $this->type = self::TYPE_NOTE; } if ($this->date === null) { $this->date = $this->timeService()->currentDateTime(); } if ($this->position === null) { $this->position = 0; } return parent::beforeValidation(); }