From dbfd2f936aaae95aabd52ac8de03b48a813bbb8f Mon Sep 17 00:00:00 2001 From: Arthur Schiwon Date: Fri, 5 May 2023 21:28:09 +0200 Subject: refactor: remove SystemTag logic from Folder into QuerySearchHelper - adds OC\SystemTag\SystemTagsInFilesDetector where the search logic is moved to Signed-off-by: Arthur Schiwon --- apps/dav/lib/SystemTag/SystemTagsInUseCollection.php | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'apps') diff --git a/apps/dav/lib/SystemTag/SystemTagsInUseCollection.php b/apps/dav/lib/SystemTag/SystemTagsInUseCollection.php index aa45e7d8f07..b57e685e7e7 100644 --- a/apps/dav/lib/SystemTag/SystemTagsInUseCollection.php +++ b/apps/dav/lib/SystemTag/SystemTagsInUseCollection.php @@ -27,6 +27,7 @@ declare(strict_types=1); namespace OCA\DAV\SystemTag; use OC\SystemTag\SystemTag; +use OC\SystemTag\SystemTagsInFilesDetector; use OC\User\NoUserException; use OCP\Files\IRootFolder; use OCP\Files\NotPermittedException; @@ -40,19 +41,22 @@ class SystemTagsInUseCollection extends SimpleCollection { protected IUserSession $userSession; protected IRootFolder $rootFolder; protected string $mediaType; - private ISystemTagManager $systemTagManager; + protected ISystemTagManager $systemTagManager; + protected SystemTagsInFilesDetector $systemTagsInFilesDetector; /** @noinspection PhpMissingParentConstructorInspection */ public function __construct( IUserSession $userSession, IRootFolder $rootFolder, ISystemTagManager $systemTagManager, + SystemTagsInFilesDetector $systemTagsInFilesDetector, string $mediaType = '' ) { $this->userSession = $userSession; $this->rootFolder = $rootFolder; $this->systemTagManager = $systemTagManager; $this->mediaType = $mediaType; + $this->systemTagsInFilesDetector = $systemTagsInFilesDetector; $this->name = 'systemtags-assigned'; if ($this->mediaType != '') { $this->name .= '/' . $this->mediaType; @@ -67,7 +71,7 @@ class SystemTagsInUseCollection extends SimpleCollection { if ($this->mediaType !== '') { throw new NotFound('Invalid media type'); } - return new self($this->userSession, $this->rootFolder, $this->systemTagManager, $name); + return new self($this->userSession, $this->rootFolder, $this->systemTagManager, $this->systemTagsInFilesDetector, $name); } /** @@ -89,7 +93,7 @@ class SystemTagsInUseCollection extends SimpleCollection { throw new Forbidden('Permission denied to read this collection'); } - $result = $userFolder->getSystemTags($this->mediaType); + $result = $this->systemTagsInFilesDetector->detectAssignedSystemTagsIn($userFolder, $this->mediaType); $children = []; foreach ($result as $tagData) { $tag = new SystemTag((string)$tagData['id'], $tagData['name'], (bool)$tagData['visibility'], (bool)$tagData['editable']); -- cgit v1.2.3