Slide 26
Slide 26 text
#[AsCommand(name: "user:create")
final class CreateUserCommand
{
public function __invoke(
OutputInterface $output,
UserRepository $userRepository,
#[Autowire(service: 'mailer')]
MailerInterface $mailer,
#[InputArgument(mode: InputArgument::REQUIRED)]
string $email,
#[InputOption(mode: InputOption::VALUE_IS_ARRAY)]
array $roles,
): int {
$user = new User($email, $role);
$userRepository->save($user);
$mailer->send(...);
}
}
@chalas_r