コード例 #1
0
 /**
  * @param InputInterface  $input
  * @param OutputInterface $output
  * @param User            $user
  * @param QuestionHelper  $questionHelper
  *
  * @return User
  */
 protected function editRealName(InputInterface $input, OutputInterface $output, User $user, QuestionHelper $questionHelper)
 {
     $realNameQuestion = new Question('Real Name [required]: ');
     $realNameQuestion->setValidator(function ($answer) {
         if (empty($answer)) {
             throw new \RuntimeException('Real Name must not be empty');
         }
         return $answer;
     });
     $realNameQuestion->setMaxAttempts(2);
     $user->setRealName($questionHelper->ask($input, $output, $realNameQuestion));
     return $user;
 }
コード例 #2
0
 /**
  * @param string $realName
  * @param string $email
  * @param array  $roles
  *
  * @return User
  */
 public function createUser($realName, $email, array $roles)
 {
     $user = new User();
     $user->setRealName($realName);
     $user->setEmail($email);
     $user->setRoles($roles);
     return $user;
 }