tagger === null) { throw new \RuntimeException('No tagger set'); } if ($this->homeFolder === null) { throw new \RuntimeException('No homeFolder set'); } $fileId = $this->homeFolder->get($path)->getId(); $currentTags = $this->tagger->getTagsForObjects([$fileId]); if (!empty($currentTags)) { $currentTags = current($currentTags); } $newTags = array_diff($tags, $currentTags); foreach ($newTags as $tag) { $this->tagger->tagAs($fileId, $tag, $path); } $deletedTags = array_diff($currentTags, $tags); foreach ($deletedTags as $tag) { $this->tagger->unTag($fileId, $tag, $path); } // TODO: re-read from tagger to make sure the // list is up to date, in case of concurrent changes ? return $tags; } }