本文整理汇总了PHP中Model\User::setPhone方法的典型用法代码示例。如果您正苦于以下问题:PHP User::setPhone方法的具体用法?PHP User::setPhone怎么用?PHP User::setPhone使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Model\User
的用法示例。
在下文中一共展示了User::setPhone方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: insertUpdateProcessing
public function insertUpdateProcessing($em, $passwordEncoder, $data, $id)
{
$update = !is_null($id);
try {
$em->beginTransaction();
if ($update) {
$user = $em->find('Model\\User', $id);
} else {
$user = new User();
}
$user->setUsername($data['username']);
//Regenerate salt and update password only if a new password is provided
if (isset($data['password']) && strlen($data['password']) > 8 && strlen($data['password']) < 1024) {
//Prepare salt
// $salt = base64_encode(mcrypt_create_iv(ceil(0.75 * 32), MCRYPT_DEV_URANDOM));
$salt = uniqid("", true);
$user->setSalt($salt);
//Encrypt password
$password = $passwordEncoder->encodePassword($data['password'], $user->getSalt());
$user->setPassword($password);
}
$user->setName($data['name']);
$user->setSurname($data['surname']);
$user->setEmail($data['email']);
$user->setPhone($data['phone']);
$user->setAddress($data['address']);
$user->setCap($data['cap']);
$user->setCity($data['city']);
$user->setProvince($data['province']);
$user->setCountry($data['country']);
//Prepare roles string
$roles = array();
if (isset($data['roles'])) {
foreach ($data['roles'] as $roleString => $val) {
$roles[] = new Role($roleString);
}
}
$user->setRoles($roles);
//Prepare accountExpiration DateTime object
$accountExpiration = new \DateTime($data['accountExpiration'], new \DateTimeZone('Europe/Rome'));
$user->setAccountExpiration($accountExpiration);
$enabled = isset($data['enabled']);
$user->setEnabled($enabled);
//Prepare credentialsExpiration DateTime object
$credentialsExpiration = new \DateTime($data['credentialsExpiration'], new \DateTimeZone('Europe/Rome'));
$user->setCredentialsExpiration($credentialsExpiration);
if ($update) {
$em->merge($user);
} else {
$em->persist($user);
}
$em->flush();
$em->commit();
} catch (\Exception $e) {
$em->rollback();
throw $e;
}
return $user->getId();
}