mirror of
https://github.com/verdigado/organization_folders.git
synced 2024-11-24 13:40:27 +01:00
added occ command to update resource
This commit is contained in:
parent
8d781f5001
commit
b025a5d0ed
2 changed files with 56 additions and 0 deletions
|
@ -27,6 +27,7 @@
|
|||
<command>OCA\OrganizationFolders\Command\OrganizationFolder\FixACLsOfOrganizationFolder</command>
|
||||
<command>OCA\OrganizationFolders\Command\Resource\CreateResource</command>
|
||||
<command>OCA\OrganizationFolders\Command\Resource\ListResources</command>
|
||||
<command>OCA\OrganizationFolders\Command\Resource\UpdateResource</command>
|
||||
<command>OCA\OrganizationFolders\Command\ResourceMember\CreateResourceMember</command>
|
||||
<command>OCA\OrganizationFolders\Command\ResourceMember\ListResourceMembers</command>
|
||||
<command>OCA\OrganizationFolders\Command\OrganizationProvider\ListOrganizationProviders</command>
|
||||
|
|
55
lib/Command/Resource/UpdateResource.php
Normal file
55
lib/Command/Resource/UpdateResource.php
Normal file
|
@ -0,0 +1,55 @@
|
|||
<?php
|
||||
|
||||
namespace OCA\OrganizationFolders\Command\Resource;
|
||||
|
||||
use OCP\DB\Exception;
|
||||
use Symfony\Component\Console\Input\InputArgument;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
use OCA\OrganizationFolders\Command\BaseCommand;
|
||||
|
||||
class UpdateResource extends BaseCommand {
|
||||
protected function configure(): void {
|
||||
$this
|
||||
->setName('organization-folders:update-resource')
|
||||
->setDescription('Update a resource')
|
||||
->addArgument('id', InputArgument::REQUIRED, 'Id of the resource to update')
|
||||
->addOption('name', null, InputOption::VALUE_OPTIONAL, 'New name of resource');
|
||||
|
||||
// folder type options
|
||||
$this
|
||||
->addOption('members-acl-permission', null, InputOption::VALUE_OPTIONAL, 'New acl permissions for members of resource')
|
||||
->addOption('managers-acl-permission', null, InputOption::VALUE_OPTIONAL, 'New acl permissions for managers of resource')
|
||||
->addOption('inherited-acl-permission', null, InputOption::VALUE_OPTIONAL, 'New acl permissions for users with access to the resource level above (or organization in case resource is top-level)');
|
||||
|
||||
parent::configure();
|
||||
}
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output): int {
|
||||
$id = $input->getArgument('id');
|
||||
$name = $input->getOption('name');
|
||||
|
||||
$membersAclPermission = $input->getOption('members-acl-permission');
|
||||
$managersAclPermission = $input->getOption('managers-acl-permission');
|
||||
$inheritedAclPermission = $input->getOption('inherited-acl-permission');
|
||||
|
||||
try {
|
||||
$resource = $this->resourceService->update(
|
||||
id: $id,
|
||||
name: $name,
|
||||
|
||||
membersAclPermission: $membersAclPermission,
|
||||
managersAclPermission: $managersAclPermission,
|
||||
inheritedAclPermission: $inheritedAclPermission,
|
||||
);
|
||||
|
||||
$this->writeTableInOutputFormat($input, $output, [$this->formatTableSerializable($resource)]);
|
||||
return 0;
|
||||
} catch (Exception $e) {
|
||||
$output->writeln("<error>Exception \"{$e->getMessage()}\" at {$e->getFile()} line {$e->getLine()}</error>");
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue