setName('talk:room:demote') ->setDescription('Demotes participants of a room to regular users') ->addArgument( 'token', InputArgument::REQUIRED, 'Token of the room in which users should be demoted' )->addArgument( 'participant', InputArgument::REQUIRED | InputArgument::IS_ARRAY, 'Demotes the given participants of the room to regular users' ); } protected function execute(InputInterface $input, OutputInterface $output): int { $token = $input->getArgument('token'); $users = $input->getArgument('participant'); try { $room = $this->manager->getRoomByToken($token); } catch (RoomNotFoundException $e) { $output->writeln('Room not found.'); return 1; } if ($room->isFederatedConversation()) { $output->writeln('Room is a federated conversation.'); return 1; } if (!in_array($room->getType(), [Room::TYPE_GROUP, Room::TYPE_PUBLIC], true)) { $output->writeln('Room is no group call.'); return 1; } try { $this->removeRoomModerators($room, $users); } catch (InvalidArgumentException $e) { $output->writeln(sprintf('%s', $e->getMessage())); return 1; } $output->writeln('Participants successfully demoted to regular users.'); return 0; } public function completeArgumentValues($argumentName, CompletionContext $context) { switch ($argumentName) { case 'token': return $this->completeTokenValues($context); case 'participant': return $this->completeParticipantValues($context); } return parent::completeArgumentValues($argumentName, $context); } }