本文整理匯總了PHP中UserIdentity::doHash方法的典型用法代碼示例。如果您正苦於以下問題:PHP UserIdentity::doHash方法的具體用法?PHP UserIdentity::doHash怎麽用?PHP UserIdentity::doHash使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類UserIdentity
的用法示例。
在下文中一共展示了UserIdentity::doHash方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: beforeSave
/**
* Hash passwords if required
* @return boolean
*/
public function beforeSave()
{
if ($this->scenario == 'create' || $this->scenario == 'admin_change_password') {
$this->password = UserIdentity::doHash($this->password);
} else {
if ($this->scenario == 'new_password') {
$this->password = UserIdentity::doHash($this->password_new);
}
}
$dataDir = Yii::getPathOfAlias('application.data');
foreach ($this->_fileFields as $field) {
$uploadFile = CUploadedFile::getInstance($this, $field);
if (!$uploadFile) {
continue;
}
$this->{$field} = $uploadFile;
$dirPath = $dataDir . '/' . strtolower(__CLASS__);
if (!file_exists($dirPath)) {
mkdir($dirPath, 0777, true);
}
if (!$this->{$field} || !$this->{$field}->saveAs($dirPath . '/' . $field . '_' . $this->id)) {
Yii::app()->user->setFlash('danger', 'problem saving image for field: ' . $field);
}
}
return parent::beforeSave();
}