federatedUserService = $federatedUserService; $this->circleService = $circlesService; $this->configService = $configService; } /** * */ protected function configure() { parent::configure(); $this->setName('circles:manage:leave') ->setDescription('simulate 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, 'set initiator type', '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 RequestBuilderException */ 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->circleLeave($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; } }