コード例 #1
0
ファイル: LoadUserData.php プロジェクト: alienpham/portfolio
 /**
  * Create and load user fixtures to database
  *
  * @param ObjectManager $manager Entity manager object
  *
  * @return void
  */
 public function load(ObjectManager $manager)
 {
     $userAdmin = new User();
     $userAdmin->setUsername('admin');
     $userAdmin->setEmail('*****@*****.**');
     $userAdmin->setPlainPassword('qwerty');
     $userAdmin->setRoles(array('ROLE_SUPER_ADMIN'));
     $userAdmin->setEnabled(true);
     $userAdmin->setExpired(false);
     $userAdmin->setLocked(false);
     $userAdmin->setAvatar($this->copyFile('summer.jpg'));
     $userAdmin->setCaricature($this->copyFile('autumn.jpg'));
     $userAdmin->setFirstname('Admin');
     $userAdmin->setLastname('User');
     $userAdmin->setPosition('CEO');
     $userAdmin->setInterests(array('games', 'sportsman'));
     $userAdmin->setDrink('tea');
     $userAdmin->setOrdering(0);
     $manager->persist($userAdmin);
     $this->addReference('user-admin', $userAdmin);
     $user = new User();
     $user->setUsername('firstuser');
     $user->setEmail('*****@*****.**');
     $user->setPlainPassword('qwerty');
     $user->setFirstname('First');
     $user->setLastname('User');
     $user->setPosition('PHP developer');
     $user->setEnabled(true);
     $user->setExpired(false);
     $user->setLocked(false);
     $user->setAvatar($this->copyFile('summer.jpg'));
     $user->setCaricature($this->copyFile('autumn.jpg'));
     $user->setInterests(array('ironman', 'art', 'detectives'));
     $user->setDrink('beer');
     $user->setOrdering(1);
     $manager->persist($user);
     $this->addReference('user-first', $user);
     $user = new User();
     $user->setUsername('seconduser');
     $user->setEmail('*****@*****.**');
     $user->setPlainPassword('qwerty');
     $user->setFirstname('Second');
     $user->setLastname('User');
     $user->setPosition('Art director, Designer');
     $user->setEnabled(true);
     $user->setExpired(false);
     $user->setLocked(false);
     $user->setAvatar($this->copyFile('summer.jpg'));
     $user->setCaricature($this->copyFile('autumn.jpg'));
     $user->setInterests(array('cyclists', 'art', 'books'));
     $user->setDrink('water');
     $user->setOrdering(2);
     $manager->persist($user);
     $this->addReference('user-second', $user);
     $manager->flush();
 }
コード例 #2
0
ファイル: LoadUserData.php プロジェクト: bolotyuh/fwdays
 /**
  * Create and load user fixtures to database
  *
  * @param ObjectManager $manager Entity manager object
  *
  * @return void
  */
 public function load(ObjectManager $manager)
 {
     $userAdmin = new User();
     $userAdmin->setUsername('Администратор');
     $userAdmin->setFullname('Super Admin');
     $userAdmin->setEmail('*****@*****.**');
     $userAdmin->setPlainPassword('qwerty');
     $userAdmin->setRoles(array('ROLE_SUPER_ADMIN'));
     $userAdmin->setEnabled(true);
     $userAdmin->setExpired(false);
     $userAdmin->setLocked(false);
     $manager->persist($userAdmin);
     $this->addReference('user-admin', $userAdmin);
     $userVolunteer = new User();
     $userVolunteer->setUsername('Волонтер');
     $userVolunteer->setFullname('Volunteer Jack');
     $userVolunteer->setEmail('*****@*****.**');
     $userVolunteer->setPlainPassword('qwerty');
     $userVolunteer->setRoles(array('ROLE_VOLUNTEER'));
     $userVolunteer->setEnabled(true);
     $userVolunteer->setExpired(false);
     $userVolunteer->setLocked(false);
     $manager->persist($userVolunteer);
     $this->addReference('user-volunteer', $userVolunteer);
     $userDefault = new User();
     $userDefault->setUsername('Пользователь');
     $userDefault->setFullname('Michael Jordan');
     $userDefault->setEmail('*****@*****.**');
     $userDefault->setPlainPassword('qwerty');
     $userDefault->addRole('ROLE_USER');
     $userDefault->setCountry('USA');
     $userDefault->setCity('Boston');
     $userDefault->setCompany('NBA');
     $userDefault->setPost('Point Guard');
     $userDefault->setEnabled(true);
     $userDefault->setExpired(false);
     $userDefault->setLocked(false);
     $manager->persist($userDefault);
     $this->addReference('user-default', $userDefault);
     $userDefault2 = new User();
     $userDefault2->setUsername('Pirate');
     $userDefault2->setFullname('Jack Sparrow');
     $userDefault2->setEmail('*****@*****.**');
     $userDefault2->setPlainPassword('qwerty');
     $userDefault2->addRole('ROLE_USER');
     $userDefault2->setCountry('Haiti');
     $userDefault2->setCity('Tortuga');
     $userDefault2->setCompany('Pirates of the Caribbean');
     $userDefault2->setPost('Captain');
     $userDefault2->setEnabled(true);
     $userDefault2->setExpired(false);
     $userDefault2->setLocked(false);
     $manager->persist($userDefault2);
     $this->addReference('user-default2', $userDefault2);
     $userDefault3 = new User();
     $userDefault3->setUsername('Spiderman');
     $userDefault3->setFullname('Peter Parker');
     $userDefault3->setEmail('*****@*****.**');
     $userDefault3->setPlainPassword('qwerty');
     $userDefault3->addRole('ROLE_USER');
     $userDefault3->setCountry('USA');
     $userDefault3->setCity('New-York');
     $userDefault3->setCompany('The New-York Times');
     $userDefault3->setPost('Journalist');
     $userDefault3->setEnabled(true);
     $userDefault3->setExpired(false);
     $userDefault3->setLocked(false);
     $manager->persist($userDefault3);
     $this->addReference('user-default3', $userDefault3);
     $userDefault4 = new User();
     $userDefault4->setUsername('Rasmus');
     $userDefault4->setFullname('Rasmus Lerdorf');
     $userDefault4->setEmail('*****@*****.**');
     $userDefault4->setPlainPassword('qwerty');
     $userDefault4->addRole('ROLE_USER');
     $userDefault4->setCountry('Greenland');
     $userDefault4->setCity('Tortuga');
     $userDefault4->setCompany('PHP');
     $userDefault4->setPost('Core developer');
     $userDefault4->setEnabled(true);
     $userDefault4->setSubscribe(false);
     $userDefault4->setExpired(false);
     $userDefault4->setLocked(false);
     $manager->persist($userDefault4);
     $this->addReference('user-default4', $userDefault4);
     for ($i = 1; $i <= 100; $i++) {
         $userDefault = new User();
         $userDefault->setUsername('Пользователь ' . $i);
         $userDefault->setFullname('Default User ' . $i);
         $userDefault->setEmail('user' . $i . '@fwdays.com');
         $userDefault->setPlainPassword('qwerty');
         $userDefault->addRole('ROLE_USER');
         $userDefault->setCountry('Ukraine');
         $userDefault->setCity('Khmelnytskyi');
         $userDefault->setCompany('Anonumous');
         $userDefault->setPost('Tester');
         $userDefault->setEnabled(true);
         $userDefault->setExpired(false);
         $userDefault->setLocked(false);
         $manager->persist($userDefault);
         $this->addReference('user-default-' . $i, $userDefault);
     }
     $manager->flush();
 }