federatedUserService = $federatedUserService; $this->circleService = $circlesService; } /** * */ protected function configure() { parent::configure(); $this->setName('circles:manage:join') ->setDescription('emulate a user joining a Team') ->addArgument('circle_id', InputArgument::REQUIRED, 'ID of the team') ->addArgument('initiator', InputArgument::REQUIRED, 'initiator to the request') ->addOption('type', '', InputOption::VALUE_REQUIRED, 'type of the initiator', '0') ->addOption('status-code', '', InputOption::VALUE_NONE, 'display status code on exception'); } /** * @param InputInterface $input * @param OutputInterface $output * * @return int * @throws FederatedEventException * @throws FederatedItemException * @throws InitiatorNotFoundException * @throws CircleNotFoundException * @throws FederatedUserException * @throws FederatedUserNotFoundException * @throws InitiatorNotConfirmedException * @throws InvalidIdException * @throws MemberNotFoundException * @throws OwnerNotFoundException * @throws RemoteInstanceException * @throws RemoteNotFoundException * @throws RemoteResourceNotFoundException * @throws RequestBuilderException * @throws SingleCircleNotFoundException * @throws UnknownRemoteException * @throws UserTypeNotFoundException */ protected function execute(InputInterface $input, OutputInterface $output): int { $circleId = (string)$input->getArgument('circle_id'); try { $this->federatedUserService->commandLineInitiator( $input->getArgument('initiator'), Member::parseTypeString($input->getOption('type')), '', false ); $outcome = $this->circleService->circleJoin($circleId); } catch (FederatedItemException $e) { if ($input->getOption('status-code')) { throw new FederatedItemException( ' [' . get_class($e) . ', ' . ((string)$e->getStatus()) . ']' . "\n" . $e->getMessage() ); } throw $e; } if (strtolower($input->getOption('output')) === 'json') { $output->writeln(json_encode($outcome, JSON_PRETTY_PRINT)); } return 0; } }