Пример #1
0
 /**
  * @return \WellCommerce\Bundle\UserBundle\Entity\RoleInterface
  */
 public function create()
 {
     $role = new Role();
     $role->setName('');
     $role->setUsers(new ArrayCollection());
     return $role;
 }
Пример #2
0
 /**
  * {@inheritDoc}
  */
 public function load(ObjectManager $manager)
 {
     $role = new Role();
     $role->setName('admin');
     $role->setRole('ROLE_ADMIN');
     $manager->persist($role);
     $user = new User();
     $user->setFirstName('John');
     $user->setLastName('Doe');
     $user->setUsername('admin');
     $user->setEmail('*****@*****.**');
     $user->setIsActive(1);
     $password = password_hash('admin', PASSWORD_BCRYPT, ['cost' => 12]);
     $user->setPassword($password);
     $user->addRole($role);
     $manager->persist($user);
     $manager->flush();
 }