federatedUserService = $federatedUserService; $this->remoteService = $remoteService; $this->circleService = $circlesService; $this->memberService = $membersService; $this->configService = $configService; } /** * */ protected function configure() { parent::configure(); $this->setName('circles:manage:details') ->setDescription('get details about a team by its ID') ->addArgument('circle_id', InputArgument::REQUIRED, 'ID of the team') ->addOption('instance', '', InputOption::VALUE_REQUIRED, 'Instance of the team', '') ->addOption('initiator', '', InputOption::VALUE_REQUIRED, 'set an initiator to the request', '') ->addOption('initiator-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 CircleNotFoundException * @throws FederatedItemException * @throws FederatedUserException * @throws FederatedUserNotFoundException * @throws InitiatorNotFoundException * @throws InvalidItemException * @throws MemberNotFoundException * @throws OwnerNotFoundException * @throws RemoteInstanceException * @throws RemoteNotFoundException * @throws RemoteResourceNotFoundException * @throws UnknownRemoteException * @throws UserTypeNotFoundException * @throws InvalidIdException * @throws RequestBuilderException * @throws SingleCircleNotFoundException */ protected function execute(InputInterface $input, OutputInterface $output): int { $circleId = (string)$input->getArgument('circle_id'); $instance = $input->getOption('instance'); try { if ($instance !== '') { $circle = $this->remoteService->getCircleFromInstance( $circleId, $instance, [ 'initiator' => $input->getOption('initiator'), 'initiatorType' => Member::parseTypeString($input->getOption('initiator-type')) ] ); } else { try { $this->federatedUserService->commandLineInitiator( $input->getOption('initiator'), Member::parseTypeString($input->getOption('initiator-type')), $circleId, true ); $probe = new CircleProbe(); $probe->includeNonVisibleCircles(); $circle = $this->circleService->getCircle($circleId, $probe); } catch (CircleNotFoundException $e) { throw new CircleNotFoundException( 'unknown circle, use --instance to retrieve the data from a remote instance' ); } } } catch (FederatedItemException $e) { if ($input->getOption('status-code')) { throw new FederatedItemException( ' [' . get_class($e) . ', ' . ((string)$e->getStatus()) . ']' . "\n" . $e->getMessage() ); } throw $e; } $output->writeln(json_encode($circle, JSON_PRETTY_PRINT)); return 0; } }