当前位置: 首页>>代码示例>>PHP>>正文


PHP User::setName方法代码示例

本文整理汇总了PHP中Model\User::setName方法的典型用法代码示例。如果您正苦于以下问题:PHP User::setName方法的具体用法?PHP User::setName怎么用?PHP User::setName使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Model\User的用法示例。


在下文中一共展示了User::setName方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
 }
开发者ID:francescocambi,项目名称:FCMS2,代码行数:59,代码来源:EditorController.php

示例2: UserBis

$damien = new UserBis();
$damien->setName('Damien');
$damien->setFavoriteCapsuleTypeAsObject(CapsuleType::fromValues('custom', 'black', 'Most metal coffee ever made', 12));
$entityManager->persist($damien);
$entityManager->flush();
sep("User with favorite type as object persisted");
var_dump($damien);
$loick = new UserBis();
$loick->setName('Loick');
try {
    $entityManager->persist($loick);
    $entityManager->flush();
    var_dump($loick);
} catch (\Exception $e) {
    echo $e->getMessage();
    /**
     * We can't save the user without the VO :-(
     */
}
$loick = new User();
$loick->setName('Loick');
try {
    $entityManager->persist($loick);
    $entityManager->flush();
    var_dump($loick);
} catch (\Exception $e) {
    echo $e->getMessage();
    /**
     * We can't save the user without the VO :-(
     */
}
开发者ID:jolicode,项目名称:value-object-conf,代码行数:31,代码来源:demo.php


注:本文中的Model\User::setName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。