Esempio n. 1
0
 /**
  * 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();
 }