Return value of "...::execute()" must be of the type int, NULL returned. Ошибка при запуске консольной команды
Primary tabs
Return value of "App\Command\AddAdminUserCommand::execute()" must be of the type int, NULL returned.
при этом реализация метода такая:
protected function execute(InputInterface $input, OutputInterface $output) { $io = new SymfonyStyle($input, $output); $pass = $input->getArgument('pass'); if ($pass) { $io->note(sprintf('You passed an argument: %s', $pass)); } $User = new User(); $User->setUsername('admin'); $User->setRoles(['ROLE_ADMIN']); // назнчаем напр. админскую роль (будет сохранена в базе) $User->setPassword($this->passwordEncoder->encodePassword( $User, $pass )); $entityManager = $this->entityManager; $entityManager->persist($User); $entityManager->flush(); $io->success('Admin user has been created'); }
Возможное решение
В случае удачного завершения метода можно просто добавить в конец:
return 0;
- Log in to post comments
- 1659 reads