protected function execute(InputInterface $input, OutputInterface $output) { $mountId = $input->getArgument('mount_id'); $configInput = $input->getOption('config'); try { $mount = $this->globalService->getStorage($mountId); } catch (NotFoundException $e) { $output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>'); return 404; } $this->updateStorageStatus($mount, $configInput, $output); $this->writeArrayInOutputFormat($input, $output, ['status' => StorageNotAvailableException::getStateCodeName($mount->getStatus()), 'code' => $mount->getStatus(), 'message' => $mount->getStatusMessage()]); }
protected function execute(InputInterface $input, OutputInterface $output) { $mountId = $input->getArgument('mount_id'); try { $mount = $this->globalService->getStorage($mountId); } catch (NotFoundException $e) { $output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts</error>'); return 404; } if ($mount->getType() === StorageConfig::MOUNT_TYPE_PERSONAl) { $output->writeln('<error>Can\'t change applicables on personal mounts</error>'); return 1; } $addUsers = $input->getOption('add-user'); $removeUsers = $input->getOption('remove-user'); $addGroups = $input->getOption('add-group'); $removeGroups = $input->getOption('remove-group'); $applicableUsers = $mount->getApplicableUsers(); $applicableGroups = $mount->getApplicableGroups(); if (count($addUsers) + count($removeUsers) + count($addGroups) + count($removeGroups) > 0 || $input->getOption('remove-all')) { foreach ($addUsers as $addUser) { if (!$this->userManager->userExists($addUser)) { $output->writeln('<error>User "' . $addUser . '" not found</error>'); return 404; } } foreach ($addGroups as $addGroup) { if (!$this->groupManager->groupExists($addGroup)) { $output->writeln('<error>Group "' . $addGroup . '" not found</error>'); return 404; } } if ($input->getOption('remove-all')) { $applicableUsers = []; $applicableGroups = []; } else { $applicableUsers = array_unique(array_merge($applicableUsers, $addUsers)); $applicableUsers = array_values(array_diff($applicableUsers, $removeUsers)); $applicableGroups = array_unique(array_merge($applicableGroups, $addGroups)); $applicableGroups = array_values(array_diff($applicableGroups, $removeGroups)); } $mount->setApplicableUsers($applicableUsers); $mount->setApplicableGroups($applicableGroups); $this->globalService->updateStorage($mount); } $this->writeArrayInOutputFormat($input, $output, ['users' => $applicableUsers, 'groups' => $applicableGroups]); }
protected function execute(InputInterface $input, OutputInterface $output) { $mountId = $input->getArgument('mount_id'); $key = $input->getArgument('key'); try { $mount = $this->globalService->getStorage($mountId); } catch (NotFoundException $e) { $output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>'); return 404; } $value = $input->getArgument('value'); if ($value) { $this->setOption($mount, $key, $value, $output); } else { $this->getOption($mount, $key, $output); } }
protected function execute(InputInterface $input, OutputInterface $output) { $mountId = $input->getArgument('mount_id'); try { $mount = $this->globalService->getStorage($mountId); } catch (NotFoundException $e) { $output->writeln('<error>Mount with id "' . $mountId . ' not found, check "occ files_external:list" to get available mounts"</error>'); return 404; } $noConfirm = $input->getOption('yes'); if (!$noConfirm) { $listCommand = new ListCommand($this->globalService, $this->userService, $this->userSession, $this->userManager); $listInput = new ArrayInput([], $listCommand->getDefinition()); $listInput->setOption('output', $input->getOption('output')); $listCommand->listMounts(null, [$mount], $listInput, $output); $questionHelper = $this->getHelper('question'); $question = new ConfirmationQuestion('Delete this mount? [y/N] ', false); if (!$questionHelper->ask($input, $output, $question)) { return; } } $this->globalService->removeStorage($mountId); }