2024-10-30 04:47:47 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace OCA\OrganizationFolders\Command\OrganizationFolder;
|
|
|
|
|
|
|
|
use OCP\DB\Exception;
|
|
|
|
use Symfony\Component\Console\Input\InputOption;
|
|
|
|
use Symfony\Component\Console\Input\InputInterface;
|
|
|
|
use Symfony\Component\Console\Output\OutputInterface;
|
|
|
|
|
|
|
|
use OCA\OrganizationFolders\Command\BaseCommand;
|
|
|
|
|
|
|
|
class CreateOrganizationFolder extends BaseCommand {
|
|
|
|
protected function configure(): void {
|
|
|
|
$this
|
|
|
|
->setName('organization-folders:create')
|
|
|
|
->setDescription('Create a new organization folder')
|
|
|
|
->addOption('name', null, InputOption::VALUE_REQUIRED, 'Name of the new organization folder')
|
2024-11-04 18:38:14 +01:00
|
|
|
->addOption('quota', null, InputOption::VALUE_REQUIRED, 'Storage Quota of the new organization folder')
|
|
|
|
->addOption('organization-provider', null, InputOption::VALUE_OPTIONAL, 'Organization provider of the organization this folder is part of')
|
|
|
|
->addOption('organization-id', null, InputOption::VALUE_OPTIONAL, 'Organization id of the organization this folder is part of');
|
2024-10-30 04:47:47 +01:00
|
|
|
parent::configure();
|
|
|
|
}
|
|
|
|
|
|
|
|
protected function execute(InputInterface $input, OutputInterface $output): int {
|
|
|
|
$name = $input->getOption('name');
|
|
|
|
$quota = $input->getOption('quota');
|
2024-11-04 18:38:14 +01:00
|
|
|
$organizationProviderId = $input->getOption('organization-provider');
|
|
|
|
$organizationId = $input->getOption('organization-id');
|
2024-10-30 04:47:47 +01:00
|
|
|
|
|
|
|
try {
|
2024-11-04 18:38:14 +01:00
|
|
|
$organizationFolder = $this->organizationFolderService->create(
|
|
|
|
name: $name,
|
|
|
|
quota: $quota,
|
|
|
|
organizationProvider: $organizationProviderId,
|
|
|
|
organizationId: $organizationId,
|
|
|
|
);
|
2024-10-30 04:47:47 +01:00
|
|
|
|
2024-11-02 20:15:32 +01:00
|
|
|
$this->writeTableInOutputFormat($input, $output, [$this->formatTableSerializable($organizationFolder)]);
|
2024-10-30 04:47:47 +01:00
|
|
|
return 0;
|
|
|
|
} catch (Exception $e) {
|
|
|
|
$output->writeln("<error>Exception \"{$e->getMessage()}\" at {$e->getFile()} line {$e->getLine()}</error>");
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|