/** * handle event * * @param string $event * * @return bool */ protected function handleEvent($event) { if ($event == self::EVENT_CREATING) { $this->setAttribute('salt', $this->_makeSalt()); $this->setAttribute('password', $this->_encryptPassword()); } elseif ($event == self::EVENT_UPDATING) { if ($this->isDirty(['password'])) { $this->setAttribute('password', $this->_encryptPassword()); } } return parent::handleEvent($event); }