setName('talk:user:remove') ->setDescription('Remove a user from all their rooms') ->addOption( 'user', null, InputOption::VALUE_REQUIRED | InputOption::VALUE_IS_ARRAY, 'Remove the given users from all rooms' ) ->addOption( 'private-only', null, InputOption::VALUE_NONE, 'Only remove the user from private rooms, retaining membership in public and open conversations as well as one-to-ones' ) ; } protected function execute(InputInterface $input, OutputInterface $output): int { $userIds = $input->getOption('user'); $privateOnly = $input->getOption('private-only'); $users = []; foreach ($userIds as $userId) { $user = $this->userManager->get($userId); if (!$user) { $output->writeln('' . sprintf("User '%s' not found.", $userId) . ''); return 1; } $users[] = $user; } foreach ($users as $user) { $this->manager->removeUserFromAllRooms($user, $privateOnly); } $output->writeln('Users successfully removed from all rooms.'); return 0; } }