コード例 #1
0
ファイル: LoadUserData.php プロジェクト: phecho/gitonomy
 /**
  * @inheritdoc
  */
 public function load(ObjectManager $manager)
 {
     $adminRole = $this->getReference('role-admin');
     $projectCreatorRole = $this->getReference('role-project-creator');
     $users = array();
     $lead = new User('lead', 'Lead', 'Europe/Paris');
     $lead->addGlobalRole($projectCreatorRole);
     $lead->createEmail('*****@*****.**', true);
     $this->setPassword($lead, 'lead');
     $users[] = $lead;
     $charlie = new User('charlie', 'Visitor', 'Europe/Paris');
     $charlie->createEmail('*****@*****.**');
     $this->setPassword($charlie, 'charlie');
     $users[] = $charlie;
     $alice = new User('alice', 'Alice', 'Europe/Paris');
     $alice->addGlobalRole($projectCreatorRole);
     $alice->createEmail('*****@*****.**', true);
     $alice->createEmail('*****@*****.**');
     $this->setPassword($alice, 'alice');
     $users[] = $alice;
     $bob = new User('bob', 'Bob', 'Europe/Paris');
     $bob->createEmail('*****@*****.**', true);
     $this->setPassword($bob, 'bob');
     $users[] = $bob;
     $inactive = new User('inactive', 'Inactive', 'Europe/Paris');
     $inactive->createEmail('*****@*****.**', true)->createActivationToken();
     $inactive->createActivationToken();
     $users[] = $inactive;
     foreach ($users as $user) {
         $manager->persist($user);
         $this->setReference('user-' . $user->getUsername(), $user);
     }
     $manager->flush();
 }
コード例 #2
0
ファイル: LoadUserData.php プロジェクト: phecho/gitonomy
 /**
  * @inheritdoc
  */
 public function load(ObjectManager $manager)
 {
     $adminRole = $this->getReference('role-admin');
     $projectCreatorRole = $this->getReference('role-project-creator');
     $admin = new User('admin', 'Admin', 'Europe/Paris');
     $admin->createEmail('*****@*****.**', true);
     $admin->addGlobalRole($adminRole);
     $admin->addGlobalRole($projectCreatorRole);
     $this->setPassword($admin, 'admin');
     $manager->persist($admin);
     $manager->flush();
 }
コード例 #3
0
ファイル: UserCreateCommand.php プロジェクト: phecho/gitonomy
 /**
  * @inheritdoc
  */
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     $em = $this->getContainer()->get('doctrine')->getManager();
     $email = $input->getArgument('email');
     $username = $input->getArgument('username');
     $password = $input->getArgument('password');
     $fullname = $input->getArgument('fullname');
     $timezone = $input->getArgument('fullname');
     $user = new User($username, $fullname, $timezone);
     $user->createEmail($email, true);
     $encoder = $this->getContainer()->get('security.encoder_factory')->getEncoder($user);
     $user->setPassword($password, $encoder);
     $em->persist($user);
     $em->flush();
     $output->writeln(sprintf('The user <info>%s</info> was successfully created!', $user->getUsername()));
 }