ISystemTagObjectMapper.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  1. <?php
  2. /**
  3. * @copyright Copyright (c) 2016, ownCloud, Inc.
  4. *
  5. * @author Joas Schilling <coding@schilljs.com>
  6. * @author Vincent Petry <pvince81@owncloud.com>
  7. *
  8. * @license AGPL-3.0
  9. *
  10. * This code is free software: you can redistribute it and/or modify
  11. * it under the terms of the GNU Affero General Public License, version 3,
  12. * as published by the Free Software Foundation.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU Affero General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Affero General Public License, version 3,
  20. * along with this program. If not, see <http://www.gnu.org/licenses/>
  21. *
  22. */
  23. namespace OCP\SystemTag;
  24. /**
  25. * Public interface to access and manage system-wide tags.
  26. *
  27. * @since 9.0.0
  28. */
  29. interface ISystemTagObjectMapper {
  30. /**
  31. * Get a list of tag ids for the given object ids.
  32. *
  33. * This returns an array that maps object id to tag ids
  34. * [
  35. * 1 => array('id1', 'id2'),
  36. * 2 => array('id3', 'id2'),
  37. * 3 => array('id5'),
  38. * 4 => array()
  39. * ]
  40. *
  41. * Untagged objects will have an empty array associated.
  42. *
  43. * @param string|array $objIds object ids
  44. * @param string $objectType object type
  45. *
  46. * @return array with object id as key and an array
  47. * of tag ids as value
  48. *
  49. * @since 9.0.0
  50. */
  51. public function getTagIdsForObjects($objIds, $objectType);
  52. /**
  53. * Get a list of objects tagged with $tagIds.
  54. *
  55. * @param string|array $tagIds Tag id or array of tag ids.
  56. * @param string $objectType object type
  57. * @param int $limit Count of object ids you want to get
  58. * @param string $offset The last object id you already received
  59. *
  60. * @return string[] array of object ids or empty array if none found
  61. *
  62. * @throws \OCP\SystemTag\TagNotFoundException if at least one of the
  63. * given tags does not exist
  64. * @throws \InvalidArgumentException When a limit is specified together with
  65. * multiple tag ids
  66. *
  67. * @since 9.0.0
  68. */
  69. public function getObjectIdsForTags($tagIds, $objectType, $limit = 0, $offset = '');
  70. /**
  71. * Assign the given tags to the given object.
  72. *
  73. * If at least one of the given tag ids doesn't exist, none of the tags
  74. * will be assigned.
  75. *
  76. * If the relationship already existed, fail silently.
  77. *
  78. * @param string $objId object id
  79. * @param string $objectType object type
  80. * @param string|array $tagIds tag id or array of tag ids to assign
  81. *
  82. * @throws \OCP\SystemTag\TagNotFoundException if at least one of the
  83. * given tags does not exist
  84. *
  85. * @since 9.0.0
  86. */
  87. public function assignTags($objId, $objectType, $tagIds);
  88. /**
  89. * Unassign the given tags from the given object.
  90. *
  91. * If at least one of the given tag ids doesn't exist, none of the tags
  92. * will be unassigned.
  93. *
  94. * If the relationship did not exist in the first place, fail silently.
  95. *
  96. * @param string $objId object id
  97. * @param string $objectType object type
  98. * @param string|array $tagIds tag id or array of tag ids to unassign
  99. *
  100. * @throws \OCP\SystemTag\TagNotFoundException if at least one of the
  101. * given tags does not exist
  102. *
  103. * @since 9.0.0
  104. */
  105. public function unassignTags($objId, $objectType, $tagIds);
  106. /**
  107. * Checks whether the given objects have the given tag.
  108. *
  109. * @param string|array $objIds object ids
  110. * @param string $objectType object type
  111. * @param string $tagId tag id to check
  112. * @param bool $all true to check that ALL objects have the tag assigned,
  113. * false to check that at least ONE object has the tag.
  114. *
  115. * @return bool true if the condition set by $all is matched, false
  116. * otherwise
  117. *
  118. * @throws \OCP\SystemTag\TagNotFoundException if the tag does not exist
  119. *
  120. * @since 9.0.0
  121. */
  122. public function haveTag($objIds, $objectType, $tagId, $all = true);
  123. }