Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nextcloud/fulltextsearch.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'lib/Command/CollectionDelete.php')
-rw-r--r--lib/Command/CollectionDelete.php89
1 files changed, 89 insertions, 0 deletions
diff --git a/lib/Command/CollectionDelete.php b/lib/Command/CollectionDelete.php
new file mode 100644
index 0000000..98b0a23
--- /dev/null
+++ b/lib/Command/CollectionDelete.php
@@ -0,0 +1,89 @@
+<?php
+declare(strict_types=1);
+
+
+/**
+ * FullTextSearch - Full text search framework for Nextcloud
+ *
+ * This file is licensed under the Affero General Public License version 3 or
+ * later. See the COPYING file.
+ *
+ * @author Maxence Lange <maxence@artificial-owl.com>
+ * @copyright 2018
+ * @license GNU AGPL version 3 or any later version
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as
+ * published by the Free Software Foundation, either version 3 of the
+ * License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ *
+ */
+
+
+namespace OCA\FullTextSearch\Command;
+
+
+use OC\Core\Command\Base;
+use OCA\FullTextSearch\Exceptions\CollectionArgumentException;
+use OCA\FullTextSearch\Service\CollectionService;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+
+
+class CollectionDelete extends Base {
+
+
+ /** @var CollectionService */
+ private $collectionService;
+
+
+ /**
+ * @param CollectionService $collectionService
+ */
+ public function __construct(CollectionService $collectionService) {
+ parent::__construct();
+
+ $this->collectionService = $collectionService;
+ }
+
+
+ /**
+ *
+ */
+ protected function configure() {
+ parent::configure();
+ $this->setName('fulltextsearch:collection:delete')
+ ->setDescription('Delete collection')
+ ->addArgument('name', InputArgument::REQUIRED, 'name of the collection to delete');
+ }
+
+
+ /**
+ * @param InputInterface $input
+ * @param OutputInterface $output
+ *
+ * @return int
+ */
+ protected function execute(InputInterface $input, OutputInterface $output) {
+ $collection = $input->getArgument('name');
+ if (!$this->collectionService->hasCollection($collection)) {
+ throw new CollectionArgumentException('unknown collection');
+ }
+
+ $this->collectionService->deleteCollection($collection);
+
+ return 0;
+ }
+}
+
+
+