setName('organization-folders:list-organizations')
->setDescription('List all organizations provided by a specific organization provider')
->addArgument('provider-id', InputArgument::REQUIRED, 'provider to query')
->addArgument('parent-organization-id', InputArgument::OPTIONAL, 'parent organization to fetch child organizations of. Using top-level if omitted');
parent::configure();
}
protected function execute(InputInterface $input, OutputInterface $output): int {
try {
$providerId = $input->getArgument('provider-id');
if(ctype_digit($input->getArgument('parent-organization-id'))) {
$parentOrganizationId = (int)$input->getArgument('parent-organization-id');
} else {
$parentOrganizationId = null;
}
if(!$this->organizationProviderManager->hasOrganizationProvider($providerId)) {
$output->writeln("organization provider not found");
return 0;
}
$organizations = $this->organizationProviderManager->getOrganizationProvider($providerId)->getSubOrganizations($parentOrganizationId);
$this->writeTableInOutputFormat($input, $output, $this->formatTableSerializables($organizations));
return 0;
} catch (Exception $e) {
$output->writeln("Exception \"{$e->getMessage()}\" at {$e->getFile()} line {$e->getLine()}");
return 1;
}
}
}