summaryrefslogtreecommitdiffstats
path: root/apps/files/service
diff options
context:
space:
mode:
authorJoas Schilling <nickvergessen@gmx.de>2016-05-12 12:07:06 +0200
committerThomas Müller <DeepDiver1975@users.noreply.github.com>2016-05-12 12:07:06 +0200
commitb34bacd0718fa24c67a8ef0aa6f3b824a9b525bb (patch)
tree904bda1263850905c2c8164f4f1367d8c7bc9d46 /apps/files/service
parenteea98f1d74daf2a20c6b08b9df743f0478c48103 (diff)
downloadnextcloud-server-b34bacd0718fa24c67a8ef0aa6f3b824a9b525bb.tar.gz
nextcloud-server-b34bacd0718fa24c67a8ef0aa6f3b824a9b525bb.zip
Move Files app to PSR-4 (#24569)
* Move lib/ of Files app to PSR-4 * Move tests to PSR-4
Diffstat (limited to 'apps/files/service')
-rw-r--r--apps/files/service/tagservice.php114
1 files changed, 0 insertions, 114 deletions
diff --git a/apps/files/service/tagservice.php b/apps/files/service/tagservice.php
deleted file mode 100644
index 57cad43a539..00000000000
--- a/apps/files/service/tagservice.php
+++ /dev/null
@@ -1,114 +0,0 @@
-<?php
-/**
- * @author Joas Schilling <nickvergessen@owncloud.com>
- * @author Morris Jobke <hey@morrisjobke.de>
- * @author Thomas Müller <thomas.mueller@tmit.eu>
- * @author Vincent Petry <pvince81@owncloud.com>
- *
- * @copyright Copyright (c) 2016, ownCloud, Inc.
- * @license AGPL-3.0
- *
- * This code is free software: you can redistribute it and/or modify
- * it under the terms of the GNU Affero General Public License, version 3,
- * as published by the Free Software Foundation.
- *
- * 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, version 3,
- * along with this program. If not, see <http://www.gnu.org/licenses/>
- *
- */
-
-namespace OCA\Files\Service;
-
-use OC\Files\FileInfo;
-use OCP\Files\Node;
-
-/**
- * Service class to manage tags on files.
- */
-class TagService {
-
- /**
- * @var \OCP\IUserSession
- */
- private $userSession;
-
- /**
- * @var \OCP\ITags
- */
- private $tagger;
-
- /**
- * @var \OCP\Files\Folder
- */
- private $homeFolder;
-
- public function __construct(
- \OCP\IUserSession $userSession,
- \OCP\ITags $tagger,
- \OCP\Files\Folder $homeFolder
- ) {
- $this->userSession = $userSession;
- $this->tagger = $tagger;
- $this->homeFolder = $homeFolder;
- }
-
- /**
- * Updates the tags of the specified file path.
- * The passed tags are absolute, which means they will
- * replace the actual tag selection.
- *
- * @param string $path path
- * @param array $tags array of tags
- * @return array list of tags
- * @throws \OCP\Files\NotFoundException if the file does not exist
- */
- public function updateFileTags($path, $tags) {
- $fileId = $this->homeFolder->get($path)->getId();
-
- $currentTags = $this->tagger->getTagsForObjects(array($fileId));
-
- if (!empty($currentTags)) {
- $currentTags = current($currentTags);
- }
-
- $newTags = array_diff($tags, $currentTags);
- foreach ($newTags as $tag) {
- $this->tagger->tagAs($fileId, $tag);
- }
- $deletedTags = array_diff($currentTags, $tags);
- foreach ($deletedTags as $tag) {
- $this->tagger->unTag($fileId, $tag);
- }
-
- // TODO: re-read from tagger to make sure the
- // list is up to date, in case of concurrent changes ?
- return $tags;
- }
-
- /**
- * Get all files for the given tag
- *
- * @param string $tagName tag name to filter by
- * @return Node[] list of matching files
- * @throws \Exception if the tag does not exist
- */
- public function getFilesByTag($tagName) {
- try {
- $fileIds = $this->tagger->getIdsForTag($tagName);
- } catch (\Exception $e) {
- return [];
- }
-
- $allNodes = [];
- foreach ($fileIds as $fileId) {
- $allNodes = array_merge($allNodes, $this->homeFolder->getById((int) $fileId));
- }
- return $allNodes;
- }
-}
-