示例#1
0
 public function handleTest()
 {
     ini_set('max_execution_time', 0);
     $limit = 10000;
     $batchSize = 20;
     $role = $this->em->getRepository('userRole')->find(1);
     for ($i = 0; $i <= $limit; $i++) {
         try {
             $user = new \Entity\User();
             $user->setName('meno' . $i);
             $user->setEmail('email' . $i . '@email.hovno');
             $user->setPassword('heslo' . $i);
             $user->setRole($role);
             $this->em->persist($user);
             if ($i % $batchSize == 0) {
                 $this->em->flush();
                 $this->em->clear();
                 $role = $this->em->getRepository('userRole')->find(1);
             }
         } catch (\Exception $e) {
         }
     }
     $this->invalidateControl('usersBrowser');
 }
示例#2
0
 /**
  * Creates new user in database from Google response data
  *
  * @param $data
  * @param \Google_Service_Oauth2_Userinfoplus $userData
  * @return \Entity\User
  */
 private function createUser($data, $userData)
 {
     $userEntity = new \Entity\User();
     $userEntity->setEmail($data['email']);
     $userEntity->setFirstName($userData['givenName']);
     $userEntity->setLastName($userData['familyName']);
     if (!$this->findOne('User')) {
         //first user
         $userEntity->setRole($this->findOne('Role'));
     }
     $this->persist($userEntity);
     $this->flush();
     return $userEntity;
 }
示例#3
0
文件: Installer.php 项目: bazo/Tatami
 /**
  *
  * @param type $login
  * @param type $password
  * @param type $email
  * @return \Entity\User 
  */
 public function createAdminUserAccount($name, $password, $email)
 {
     $user = new \Entity\User();
     $user->setName($name);
     $user->setPassword($password);
     $user->setEmail($email);
     $adminRole = $this->entityManager->getRepository('UserRole')->findOneBy(array('name' => 'Admin'));
     $user->setRole($adminRole);
     $this->entityManager->persist($user);
     $this->entityManager->flush();
     return $user;
 }