diff --git a/src/Sylius/Bundle/AdminBundle/Console/Command/ListAdminUsersCommand.php b/src/Sylius/Bundle/AdminBundle/Console/Command/ListAdminUsersCommand.php new file mode 100644 index 00000000000..0985eec4d16 --- /dev/null +++ b/src/Sylius/Bundle/AdminBundle/Console/Command/ListAdminUsersCommand.php @@ -0,0 +1,76 @@ + $userRepositoryInterface */ + public function __construct( + private readonly UserRepositoryInterface $userRepositoryInterface + ) { + parent::__construct(); + } + + protected function initialize(InputInterface $input, OutputInterface $output): void + { + $this->io = new SymfonyStyle($input, $output); + } + + /** + * @param InputInterface $input + * @param OutputInterface $output + * @return int + */ + protected function execute(InputInterface $input, OutputInterface $output): int + { + $this->io->title('List available admin users'); + + $adminUsers = $this->userRepositoryInterface->findAll(); + /** @var AdminUser $adminUser */ + foreach ($adminUsers as $adminUser) { + $this->io->table( + [ + 'ID', 'E-Mail', 'Username', 'First name', 'Last name', 'Locale code', 'Enabled', + ], + [ + [ + $adminUser->getId(), + $adminUser->getEmail(), + $adminUser->getUsername(), + $adminUser->getFirstname() ?? 'No Firstname Set', + $adminUser->getLastName() ?? 'No Lastname Set', + $adminUser->getLocaleCode(), + $adminUser->isEnabled() ? 'Enabled' : 'Disabled', + ], + ], + ); + } + return Command::SUCCESS; + } +} diff --git a/src/Sylius/Bundle/AdminBundle/Resources/config/services.xml b/src/Sylius/Bundle/AdminBundle/Resources/config/services.xml index b52eeea8181..8eac394fa5c 100644 --- a/src/Sylius/Bundle/AdminBundle/Resources/config/services.xml +++ b/src/Sylius/Bundle/AdminBundle/Resources/config/services.xml @@ -49,6 +49,11 @@ + + + + +