예제 #1
0
 private function createAdminUser($formData, $em)
 {
     $username = $formData['username'];
     $email = $formData['email'];
     $password = $formData['password'];
     //Create the default admin role
     $adminRole = new Role();
     $adminRole->setRole("ROLE_ADMIN");
     $adminRole->setName("Administrator");
     //Create the default super admin role
     $superAdminRole = new Role();
     $superAdminRole->setRole("ROLE_SUPER_ADMIN");
     $superAdminRole->setName("Super Administrator");
     //Create the default developer admin role
     $maintenanceRole = new Role();
     $maintenanceRole->setRole("ROLE_MAINTENANCE");
     $maintenanceRole->setName("Maintenance User");
     //Create the default admin user
     $user = new User();
     $user->setUsername($username);
     $user->setEmail($email);
     $user->setCreatedBy("System");
     $user->setModifiedBy("System");
     $user->addRole($adminRole);
     $user->addRole($superAdminRole);
     $user->addRole($maintenanceRole);
     $factory = $this->container->get('security.encoder_factory');
     $encoder = $factory->getEncoder($user);
     $password = $encoder->encodePassword($password, $user->getSalt());
     $user->setPassword($password);
     $em->persist($adminRole);
     $em->persist($superAdminRole);
     $em->persist($maintenanceRole);
     $em->persist($user);
 }
예제 #2
0
 private function createAdminUser($om)
 {
     //Create the default admin role
     $adminRole = new Role();
     $adminRole->setRole("ROLE_ADMIN");
     $adminRole->setName("Administrator");
     //Create the default super admin role
     $superAdminRole = new Role();
     $superAdminRole->setRole("ROLE_SUPER_ADMIN");
     $superAdminRole->setName("Super Administrator");
     //Create the default developer admin role
     $maintenanceRole = new Role();
     $maintenanceRole->setRole("ROLE_MAINTENANCE");
     $maintenanceRole->setName("Maintenance User");
     //Create the default admin user
     $user = new User();
     $user->setUsername("admin");
     $user->setEmail("*****@*****.**");
     $user->addRole($adminRole);
     $user->addRole($superAdminRole);
     $user->addRole($maintenanceRole);
     $factory = $this->container->get('security.encoder_factory');
     $encoder = $factory->getEncoder($user);
     $password = $encoder->encodePassword('admin', $user->getSalt());
     $user->setPassword($password);
     $om->persist($adminRole);
     $om->persist($superAdminRole);
     $om->persist($maintenanceRole);
     $om->persist($user);
 }