@@ -33,133 +33,133 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | interface ISystemTagManager { |
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * Returns the tag objects matching the given tag ids. |
|
| 38 | - * |
|
| 39 | - * @param array|string $tagIds id or array of unique ids of the tag to retrieve |
|
| 40 | - * |
|
| 41 | - * @return ISystemTag[] array of system tags with tag id as key |
|
| 42 | - * |
|
| 43 | - * @throws \InvalidArgumentException if at least one given tag ids is invalid (string instead of integer, etc.) |
|
| 44 | - * @throws TagNotFoundException if at least one given tag ids did no exist |
|
| 45 | - * The message contains a json_encoded array of the ids that could not be found |
|
| 46 | - * |
|
| 47 | - * @since 9.0.0 |
|
| 48 | - */ |
|
| 49 | - public function getTagsByIds($tagIds): array; |
|
| 36 | + /** |
|
| 37 | + * Returns the tag objects matching the given tag ids. |
|
| 38 | + * |
|
| 39 | + * @param array|string $tagIds id or array of unique ids of the tag to retrieve |
|
| 40 | + * |
|
| 41 | + * @return ISystemTag[] array of system tags with tag id as key |
|
| 42 | + * |
|
| 43 | + * @throws \InvalidArgumentException if at least one given tag ids is invalid (string instead of integer, etc.) |
|
| 44 | + * @throws TagNotFoundException if at least one given tag ids did no exist |
|
| 45 | + * The message contains a json_encoded array of the ids that could not be found |
|
| 46 | + * |
|
| 47 | + * @since 9.0.0 |
|
| 48 | + */ |
|
| 49 | + public function getTagsByIds($tagIds): array; |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Returns the tag object matching the given attributes. |
|
| 53 | - * |
|
| 54 | - * @param string $tagName tag name |
|
| 55 | - * @param bool $userVisible whether the tag is visible by users |
|
| 56 | - * @param bool $userAssignable whether the tag is assignable by users |
|
| 57 | - * |
|
| 58 | - * @return ISystemTag system tag |
|
| 59 | - * |
|
| 60 | - * @throws TagNotFoundException if tag does not exist |
|
| 61 | - * |
|
| 62 | - * @since 9.0.0 |
|
| 63 | - */ |
|
| 64 | - public function getTag(string $tagName, bool $userVisible, bool $userAssignable): ISystemTag; |
|
| 51 | + /** |
|
| 52 | + * Returns the tag object matching the given attributes. |
|
| 53 | + * |
|
| 54 | + * @param string $tagName tag name |
|
| 55 | + * @param bool $userVisible whether the tag is visible by users |
|
| 56 | + * @param bool $userAssignable whether the tag is assignable by users |
|
| 57 | + * |
|
| 58 | + * @return ISystemTag system tag |
|
| 59 | + * |
|
| 60 | + * @throws TagNotFoundException if tag does not exist |
|
| 61 | + * |
|
| 62 | + * @since 9.0.0 |
|
| 63 | + */ |
|
| 64 | + public function getTag(string $tagName, bool $userVisible, bool $userAssignable): ISystemTag; |
|
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * Creates the tag object using the given attributes. |
|
| 68 | - * |
|
| 69 | - * @param string $tagName tag name |
|
| 70 | - * @param bool $userVisible whether the tag is visible by users |
|
| 71 | - * @param bool $userAssignable whether the tag is assignable by users |
|
| 72 | - * |
|
| 73 | - * @return ISystemTag system tag |
|
| 74 | - * |
|
| 75 | - * @throws TagAlreadyExistsException if tag already exists |
|
| 76 | - * |
|
| 77 | - * @since 9.0.0 |
|
| 78 | - */ |
|
| 79 | - public function createTag(string $tagName, bool $userVisible, bool $userAssignable): ISystemTag; |
|
| 66 | + /** |
|
| 67 | + * Creates the tag object using the given attributes. |
|
| 68 | + * |
|
| 69 | + * @param string $tagName tag name |
|
| 70 | + * @param bool $userVisible whether the tag is visible by users |
|
| 71 | + * @param bool $userAssignable whether the tag is assignable by users |
|
| 72 | + * |
|
| 73 | + * @return ISystemTag system tag |
|
| 74 | + * |
|
| 75 | + * @throws TagAlreadyExistsException if tag already exists |
|
| 76 | + * |
|
| 77 | + * @since 9.0.0 |
|
| 78 | + */ |
|
| 79 | + public function createTag(string $tagName, bool $userVisible, bool $userAssignable): ISystemTag; |
|
| 80 | 80 | |
| 81 | - /** |
|
| 82 | - * Returns all known tags, optionally filtered by visibility. |
|
| 83 | - * |
|
| 84 | - * @param bool|null $visibilityFilter filter by visibility if non-null |
|
| 85 | - * @param string $nameSearchPattern optional search pattern for the tag name |
|
| 86 | - * |
|
| 87 | - * @return ISystemTag[] array of system tags or empty array if none found |
|
| 88 | - * |
|
| 89 | - * @since 9.0.0 |
|
| 90 | - */ |
|
| 91 | - public function getAllTags($visibilityFilter = null, $nameSearchPattern = null): array; |
|
| 81 | + /** |
|
| 82 | + * Returns all known tags, optionally filtered by visibility. |
|
| 83 | + * |
|
| 84 | + * @param bool|null $visibilityFilter filter by visibility if non-null |
|
| 85 | + * @param string $nameSearchPattern optional search pattern for the tag name |
|
| 86 | + * |
|
| 87 | + * @return ISystemTag[] array of system tags or empty array if none found |
|
| 88 | + * |
|
| 89 | + * @since 9.0.0 |
|
| 90 | + */ |
|
| 91 | + public function getAllTags($visibilityFilter = null, $nameSearchPattern = null): array; |
|
| 92 | 92 | |
| 93 | - /** |
|
| 94 | - * Updates the given tag |
|
| 95 | - * |
|
| 96 | - * @param string $tagId tag id |
|
| 97 | - * @param string $newName the new tag name |
|
| 98 | - * @param bool $userVisible whether the tag is visible by users |
|
| 99 | - * @param bool $userAssignable whether the tag is assignable by users |
|
| 100 | - * |
|
| 101 | - * @throws TagNotFoundException if tag with the given id does not exist |
|
| 102 | - * @throws TagAlreadyExistsException if there is already another tag |
|
| 103 | - * with the same attributes |
|
| 104 | - * |
|
| 105 | - * @since 9.0.0 |
|
| 106 | - */ |
|
| 107 | - public function updateTag(string $tagId, string $newName, bool $userVisible, bool $userAssignable); |
|
| 93 | + /** |
|
| 94 | + * Updates the given tag |
|
| 95 | + * |
|
| 96 | + * @param string $tagId tag id |
|
| 97 | + * @param string $newName the new tag name |
|
| 98 | + * @param bool $userVisible whether the tag is visible by users |
|
| 99 | + * @param bool $userAssignable whether the tag is assignable by users |
|
| 100 | + * |
|
| 101 | + * @throws TagNotFoundException if tag with the given id does not exist |
|
| 102 | + * @throws TagAlreadyExistsException if there is already another tag |
|
| 103 | + * with the same attributes |
|
| 104 | + * |
|
| 105 | + * @since 9.0.0 |
|
| 106 | + */ |
|
| 107 | + public function updateTag(string $tagId, string $newName, bool $userVisible, bool $userAssignable); |
|
| 108 | 108 | |
| 109 | - /** |
|
| 110 | - * Delete the given tags from the database and all their relationships. |
|
| 111 | - * |
|
| 112 | - * @param string|array $tagIds array of tag ids |
|
| 113 | - * |
|
| 114 | - * @throws TagNotFoundException if at least one tag did not exist |
|
| 115 | - * |
|
| 116 | - * @since 9.0.0 |
|
| 117 | - */ |
|
| 118 | - public function deleteTags($tagIds); |
|
| 109 | + /** |
|
| 110 | + * Delete the given tags from the database and all their relationships. |
|
| 111 | + * |
|
| 112 | + * @param string|array $tagIds array of tag ids |
|
| 113 | + * |
|
| 114 | + * @throws TagNotFoundException if at least one tag did not exist |
|
| 115 | + * |
|
| 116 | + * @since 9.0.0 |
|
| 117 | + */ |
|
| 118 | + public function deleteTags($tagIds); |
|
| 119 | 119 | |
| 120 | - /** |
|
| 121 | - * Checks whether the given user is allowed to assign/unassign the tag with the |
|
| 122 | - * given id. |
|
| 123 | - * |
|
| 124 | - * @param ISystemTag $tag tag to check permission for |
|
| 125 | - * @param IUser $user user to check permission for |
|
| 126 | - * |
|
| 127 | - * @return true if the user is allowed to assign/unassign the tag, false otherwise |
|
| 128 | - * |
|
| 129 | - * @since 9.1.0 |
|
| 130 | - */ |
|
| 131 | - public function canUserAssignTag(ISystemTag $tag, IUser $user): bool; |
|
| 120 | + /** |
|
| 121 | + * Checks whether the given user is allowed to assign/unassign the tag with the |
|
| 122 | + * given id. |
|
| 123 | + * |
|
| 124 | + * @param ISystemTag $tag tag to check permission for |
|
| 125 | + * @param IUser $user user to check permission for |
|
| 126 | + * |
|
| 127 | + * @return true if the user is allowed to assign/unassign the tag, false otherwise |
|
| 128 | + * |
|
| 129 | + * @since 9.1.0 |
|
| 130 | + */ |
|
| 131 | + public function canUserAssignTag(ISystemTag $tag, IUser $user): bool; |
|
| 132 | 132 | |
| 133 | - /** |
|
| 134 | - * Checks whether the given user is allowed to see the tag with the given id. |
|
| 135 | - * |
|
| 136 | - * @param ISystemTag $tag tag to check permission for |
|
| 137 | - * @param IUser $user user to check permission for |
|
| 138 | - * |
|
| 139 | - * @return true if the user can see the tag, false otherwise |
|
| 140 | - * |
|
| 141 | - * @since 9.1.0 |
|
| 142 | - */ |
|
| 143 | - public function canUserSeeTag(ISystemTag $tag, IUser $user): bool; |
|
| 133 | + /** |
|
| 134 | + * Checks whether the given user is allowed to see the tag with the given id. |
|
| 135 | + * |
|
| 136 | + * @param ISystemTag $tag tag to check permission for |
|
| 137 | + * @param IUser $user user to check permission for |
|
| 138 | + * |
|
| 139 | + * @return true if the user can see the tag, false otherwise |
|
| 140 | + * |
|
| 141 | + * @since 9.1.0 |
|
| 142 | + */ |
|
| 143 | + public function canUserSeeTag(ISystemTag $tag, IUser $user): bool; |
|
| 144 | 144 | |
| 145 | - /** |
|
| 146 | - * Set groups that can assign a given tag. |
|
| 147 | - * |
|
| 148 | - * @param ISystemTag $tag tag for group assignment |
|
| 149 | - * @param string[] $groupIds group ids of groups that can assign/unassign the tag |
|
| 150 | - * |
|
| 151 | - * @since 9.1.0 |
|
| 152 | - */ |
|
| 153 | - public function setTagGroups(ISystemTag $tag, array $groupIds); |
|
| 145 | + /** |
|
| 146 | + * Set groups that can assign a given tag. |
|
| 147 | + * |
|
| 148 | + * @param ISystemTag $tag tag for group assignment |
|
| 149 | + * @param string[] $groupIds group ids of groups that can assign/unassign the tag |
|
| 150 | + * |
|
| 151 | + * @since 9.1.0 |
|
| 152 | + */ |
|
| 153 | + public function setTagGroups(ISystemTag $tag, array $groupIds); |
|
| 154 | 154 | |
| 155 | - /** |
|
| 156 | - * Get groups that can assign a given tag. |
|
| 157 | - * |
|
| 158 | - * @param ISystemTag $tag tag for group assignment |
|
| 159 | - * |
|
| 160 | - * @return string[] group ids of groups that can assign/unassign the tag |
|
| 161 | - * |
|
| 162 | - * @since 9.1.0 |
|
| 163 | - */ |
|
| 164 | - public function getTagGroups(ISystemTag $tag): array; |
|
| 155 | + /** |
|
| 156 | + * Get groups that can assign a given tag. |
|
| 157 | + * |
|
| 158 | + * @param ISystemTag $tag tag for group assignment |
|
| 159 | + * |
|
| 160 | + * @return string[] group ids of groups that can assign/unassign the tag |
|
| 161 | + * |
|
| 162 | + * @since 9.1.0 |
|
| 163 | + */ |
|
| 164 | + public function getTagGroups(ISystemTag $tag): array; |
|
| 165 | 165 | } |
@@ -32,28 +32,28 @@ |
||
| 32 | 32 | */ |
| 33 | 33 | class TagNotFoundException extends \RuntimeException { |
| 34 | 34 | |
| 35 | - /** @var string[] */ |
|
| 36 | - protected $tags; |
|
| 35 | + /** @var string[] */ |
|
| 36 | + protected $tags; |
|
| 37 | 37 | |
| 38 | - /** |
|
| 39 | - * TagNotFoundException constructor. |
|
| 40 | - * |
|
| 41 | - * @param string $message |
|
| 42 | - * @param int $code |
|
| 43 | - * @param \Exception|null $previous |
|
| 44 | - * @param string[] $tags |
|
| 45 | - * @since 9.0.0 |
|
| 46 | - */ |
|
| 47 | - public function __construct(string $message = '', int $code = 0, \Exception $previous = null, array $tags = []) { |
|
| 48 | - parent::__construct($message, $code, $previous); |
|
| 49 | - $this->tags = $tags; |
|
| 50 | - } |
|
| 38 | + /** |
|
| 39 | + * TagNotFoundException constructor. |
|
| 40 | + * |
|
| 41 | + * @param string $message |
|
| 42 | + * @param int $code |
|
| 43 | + * @param \Exception|null $previous |
|
| 44 | + * @param string[] $tags |
|
| 45 | + * @since 9.0.0 |
|
| 46 | + */ |
|
| 47 | + public function __construct(string $message = '', int $code = 0, \Exception $previous = null, array $tags = []) { |
|
| 48 | + parent::__construct($message, $code, $previous); |
|
| 49 | + $this->tags = $tags; |
|
| 50 | + } |
|
| 51 | 51 | |
| 52 | - /** |
|
| 53 | - * @return string[] |
|
| 54 | - * @since 9.0.0 |
|
| 55 | - */ |
|
| 56 | - public function getMissingTags(): array { |
|
| 57 | - return $this->tags; |
|
| 58 | - } |
|
| 52 | + /** |
|
| 53 | + * @return string[] |
|
| 54 | + * @since 9.0.0 |
|
| 55 | + */ |
|
| 56 | + public function getMissingTags(): array { |
|
| 57 | + return $this->tags; |
|
| 58 | + } |
|
| 59 | 59 | } |
@@ -33,46 +33,46 @@ |
||
| 33 | 33 | */ |
| 34 | 34 | class SystemTagsEntityEvent extends Event { |
| 35 | 35 | |
| 36 | - const EVENT_ENTITY = 'OCP\SystemTag\ISystemTagManager::registerEntity'; |
|
| 36 | + const EVENT_ENTITY = 'OCP\SystemTag\ISystemTagManager::registerEntity'; |
|
| 37 | 37 | |
| 38 | - /** @var string */ |
|
| 39 | - protected $event; |
|
| 40 | - /** @var \Closure[] */ |
|
| 41 | - protected $collections; |
|
| 38 | + /** @var string */ |
|
| 39 | + protected $event; |
|
| 40 | + /** @var \Closure[] */ |
|
| 41 | + protected $collections; |
|
| 42 | 42 | |
| 43 | - /** |
|
| 44 | - * SystemTagsEntityEvent constructor. |
|
| 45 | - * |
|
| 46 | - * @param string $event |
|
| 47 | - * @since 9.1.0 |
|
| 48 | - */ |
|
| 49 | - public function __construct(string $event) { |
|
| 50 | - $this->event = $event; |
|
| 51 | - $this->collections = []; |
|
| 52 | - } |
|
| 43 | + /** |
|
| 44 | + * SystemTagsEntityEvent constructor. |
|
| 45 | + * |
|
| 46 | + * @param string $event |
|
| 47 | + * @since 9.1.0 |
|
| 48 | + */ |
|
| 49 | + public function __construct(string $event) { |
|
| 50 | + $this->event = $event; |
|
| 51 | + $this->collections = []; |
|
| 52 | + } |
|
| 53 | 53 | |
| 54 | - /** |
|
| 55 | - * @param string $name |
|
| 56 | - * @param \Closure $entityExistsFunction The closure should take one |
|
| 57 | - * argument, which is the id of the entity, that tags |
|
| 58 | - * should be handled for. The return should then be bool, |
|
| 59 | - * depending on whether tags are allowed (true) or not. |
|
| 60 | - * @throws \OutOfBoundsException when the entity name is already taken |
|
| 61 | - * @since 9.1.0 |
|
| 62 | - */ |
|
| 63 | - public function addEntityCollection(string $name, \Closure $entityExistsFunction) { |
|
| 64 | - if (isset($this->collections[$name])) { |
|
| 65 | - throw new \OutOfBoundsException('Duplicate entity name "' . $name . '"'); |
|
| 66 | - } |
|
| 54 | + /** |
|
| 55 | + * @param string $name |
|
| 56 | + * @param \Closure $entityExistsFunction The closure should take one |
|
| 57 | + * argument, which is the id of the entity, that tags |
|
| 58 | + * should be handled for. The return should then be bool, |
|
| 59 | + * depending on whether tags are allowed (true) or not. |
|
| 60 | + * @throws \OutOfBoundsException when the entity name is already taken |
|
| 61 | + * @since 9.1.0 |
|
| 62 | + */ |
|
| 63 | + public function addEntityCollection(string $name, \Closure $entityExistsFunction) { |
|
| 64 | + if (isset($this->collections[$name])) { |
|
| 65 | + throw new \OutOfBoundsException('Duplicate entity name "' . $name . '"'); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - $this->collections[$name] = $entityExistsFunction; |
|
| 69 | - } |
|
| 68 | + $this->collections[$name] = $entityExistsFunction; |
|
| 69 | + } |
|
| 70 | 70 | |
| 71 | - /** |
|
| 72 | - * @return \Closure[] |
|
| 73 | - * @since 9.1.0 |
|
| 74 | - */ |
|
| 75 | - public function getEntityCollections(): array { |
|
| 76 | - return $this->collections; |
|
| 77 | - } |
|
| 71 | + /** |
|
| 72 | + * @return \Closure[] |
|
| 73 | + * @since 9.1.0 |
|
| 74 | + */ |
|
| 75 | + public function getEntityCollections(): array { |
|
| 76 | + return $this->collections; |
|
| 77 | + } |
|
| 78 | 78 | } |
@@ -34,56 +34,56 @@ |
||
| 34 | 34 | */ |
| 35 | 35 | class ManagerEvent extends Event { |
| 36 | 36 | |
| 37 | - const EVENT_CREATE = 'OCP\SystemTag\ISystemTagManager::createTag'; |
|
| 38 | - const EVENT_UPDATE = 'OCP\SystemTag\ISystemTagManager::updateTag'; |
|
| 39 | - const EVENT_DELETE = 'OCP\SystemTag\ISystemTagManager::deleteTag'; |
|
| 37 | + const EVENT_CREATE = 'OCP\SystemTag\ISystemTagManager::createTag'; |
|
| 38 | + const EVENT_UPDATE = 'OCP\SystemTag\ISystemTagManager::updateTag'; |
|
| 39 | + const EVENT_DELETE = 'OCP\SystemTag\ISystemTagManager::deleteTag'; |
|
| 40 | 40 | |
| 41 | - /** @var string */ |
|
| 42 | - protected $event; |
|
| 43 | - /** @var ISystemTag */ |
|
| 44 | - protected $tag; |
|
| 45 | - /** @var ISystemTag */ |
|
| 46 | - protected $beforeTag; |
|
| 41 | + /** @var string */ |
|
| 42 | + protected $event; |
|
| 43 | + /** @var ISystemTag */ |
|
| 44 | + protected $tag; |
|
| 45 | + /** @var ISystemTag */ |
|
| 46 | + protected $beforeTag; |
|
| 47 | 47 | |
| 48 | - /** |
|
| 49 | - * DispatcherEvent constructor. |
|
| 50 | - * |
|
| 51 | - * @param string $event |
|
| 52 | - * @param ISystemTag $tag |
|
| 53 | - * @param ISystemTag|null $beforeTag |
|
| 54 | - * @since 9.0.0 |
|
| 55 | - */ |
|
| 56 | - public function __construct(string $event, ISystemTag $tag, ISystemTag $beforeTag = null) { |
|
| 57 | - $this->event = $event; |
|
| 58 | - $this->tag = $tag; |
|
| 59 | - $this->beforeTag = $beforeTag; |
|
| 60 | - } |
|
| 48 | + /** |
|
| 49 | + * DispatcherEvent constructor. |
|
| 50 | + * |
|
| 51 | + * @param string $event |
|
| 52 | + * @param ISystemTag $tag |
|
| 53 | + * @param ISystemTag|null $beforeTag |
|
| 54 | + * @since 9.0.0 |
|
| 55 | + */ |
|
| 56 | + public function __construct(string $event, ISystemTag $tag, ISystemTag $beforeTag = null) { |
|
| 57 | + $this->event = $event; |
|
| 58 | + $this->tag = $tag; |
|
| 59 | + $this->beforeTag = $beforeTag; |
|
| 60 | + } |
|
| 61 | 61 | |
| 62 | - /** |
|
| 63 | - * @return string |
|
| 64 | - * @since 9.0.0 |
|
| 65 | - */ |
|
| 66 | - public function getEvent(): string { |
|
| 67 | - return $this->event; |
|
| 68 | - } |
|
| 62 | + /** |
|
| 63 | + * @return string |
|
| 64 | + * @since 9.0.0 |
|
| 65 | + */ |
|
| 66 | + public function getEvent(): string { |
|
| 67 | + return $this->event; |
|
| 68 | + } |
|
| 69 | 69 | |
| 70 | - /** |
|
| 71 | - * @return ISystemTag |
|
| 72 | - * @since 9.0.0 |
|
| 73 | - */ |
|
| 74 | - public function getTag(): ISystemTag { |
|
| 75 | - return $this->tag; |
|
| 76 | - } |
|
| 70 | + /** |
|
| 71 | + * @return ISystemTag |
|
| 72 | + * @since 9.0.0 |
|
| 73 | + */ |
|
| 74 | + public function getTag(): ISystemTag { |
|
| 75 | + return $this->tag; |
|
| 76 | + } |
|
| 77 | 77 | |
| 78 | - /** |
|
| 79 | - * @return ISystemTag |
|
| 80 | - * @since 9.0.0 |
|
| 81 | - * @throws \BadMethodCallException |
|
| 82 | - */ |
|
| 83 | - public function getTagBefore(): ISystemTag { |
|
| 84 | - if ($this->event !== self::EVENT_UPDATE) { |
|
| 85 | - throw new \BadMethodCallException('getTagBefore is only available on the update Event'); |
|
| 86 | - } |
|
| 87 | - return $this->beforeTag; |
|
| 88 | - } |
|
| 78 | + /** |
|
| 79 | + * @return ISystemTag |
|
| 80 | + * @since 9.0.0 |
|
| 81 | + * @throws \BadMethodCallException |
|
| 82 | + */ |
|
| 83 | + public function getTagBefore(): ISystemTag { |
|
| 84 | + if ($this->event !== self::EVENT_UPDATE) { |
|
| 85 | + throw new \BadMethodCallException('getTagBefore is only available on the update Event'); |
|
| 86 | + } |
|
| 87 | + return $this->beforeTag; |
|
| 88 | + } |
|
| 89 | 89 | } |
@@ -30,41 +30,41 @@ |
||
| 30 | 30 | */ |
| 31 | 31 | interface ISystemTag { |
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * Returns the tag id |
|
| 35 | - * |
|
| 36 | - * @return string id |
|
| 37 | - * |
|
| 38 | - * @since 9.0.0 |
|
| 39 | - */ |
|
| 40 | - public function getId(): string; |
|
| 33 | + /** |
|
| 34 | + * Returns the tag id |
|
| 35 | + * |
|
| 36 | + * @return string id |
|
| 37 | + * |
|
| 38 | + * @since 9.0.0 |
|
| 39 | + */ |
|
| 40 | + public function getId(): string; |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * Returns the tag display name |
|
| 44 | - * |
|
| 45 | - * @return string tag display name |
|
| 46 | - * |
|
| 47 | - * @since 9.0.0 |
|
| 48 | - */ |
|
| 49 | - public function getName(): string; |
|
| 42 | + /** |
|
| 43 | + * Returns the tag display name |
|
| 44 | + * |
|
| 45 | + * @return string tag display name |
|
| 46 | + * |
|
| 47 | + * @since 9.0.0 |
|
| 48 | + */ |
|
| 49 | + public function getName(): string; |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Returns whether the tag is visible for regular users |
|
| 53 | - * |
|
| 54 | - * @return bool true if visible, false otherwise |
|
| 55 | - * |
|
| 56 | - * @since 9.0.0 |
|
| 57 | - */ |
|
| 58 | - public function isUserVisible(): bool; |
|
| 51 | + /** |
|
| 52 | + * Returns whether the tag is visible for regular users |
|
| 53 | + * |
|
| 54 | + * @return bool true if visible, false otherwise |
|
| 55 | + * |
|
| 56 | + * @since 9.0.0 |
|
| 57 | + */ |
|
| 58 | + public function isUserVisible(): bool; |
|
| 59 | 59 | |
| 60 | - /** |
|
| 61 | - * Returns whether the tag can be assigned to objects by regular users |
|
| 62 | - * |
|
| 63 | - * @return bool true if assignable, false otherwise |
|
| 64 | - * |
|
| 65 | - * @since 9.0.0 |
|
| 66 | - */ |
|
| 67 | - public function isUserAssignable(): bool; |
|
| 60 | + /** |
|
| 61 | + * Returns whether the tag can be assigned to objects by regular users |
|
| 62 | + * |
|
| 63 | + * @return bool true if assignable, false otherwise |
|
| 64 | + * |
|
| 65 | + * @since 9.0.0 |
|
| 66 | + */ |
|
| 67 | + public function isUserAssignable(): bool; |
|
| 68 | 68 | |
| 69 | 69 | } |
| 70 | 70 | |
@@ -43,389 +43,389 @@ |
||
| 43 | 43 | */ |
| 44 | 44 | class SystemTagManager implements ISystemTagManager { |
| 45 | 45 | |
| 46 | - const TAG_TABLE = 'systemtag'; |
|
| 47 | - const TAG_GROUP_TABLE = 'systemtag_group'; |
|
| 48 | - |
|
| 49 | - /** @var IDBConnection */ |
|
| 50 | - protected $connection; |
|
| 51 | - |
|
| 52 | - /** @var EventDispatcherInterface */ |
|
| 53 | - protected $dispatcher; |
|
| 54 | - |
|
| 55 | - /** @var IGroupManager */ |
|
| 56 | - protected $groupManager; |
|
| 57 | - |
|
| 58 | - /** |
|
| 59 | - * Prepared query for selecting tags directly |
|
| 60 | - * |
|
| 61 | - * @var \OCP\DB\QueryBuilder\IQueryBuilder |
|
| 62 | - */ |
|
| 63 | - private $selectTagQuery; |
|
| 64 | - |
|
| 65 | - /** |
|
| 66 | - * Constructor. |
|
| 67 | - * |
|
| 68 | - * @param IDBConnection $connection database connection |
|
| 69 | - * @param IGroupManager $groupManager |
|
| 70 | - * @param EventDispatcherInterface $dispatcher |
|
| 71 | - */ |
|
| 72 | - public function __construct( |
|
| 73 | - IDBConnection $connection, |
|
| 74 | - IGroupManager $groupManager, |
|
| 75 | - EventDispatcherInterface $dispatcher |
|
| 76 | - ) { |
|
| 77 | - $this->connection = $connection; |
|
| 78 | - $this->groupManager = $groupManager; |
|
| 79 | - $this->dispatcher = $dispatcher; |
|
| 80 | - |
|
| 81 | - $query = $this->connection->getQueryBuilder(); |
|
| 82 | - $this->selectTagQuery = $query->select('*') |
|
| 83 | - ->from(self::TAG_TABLE) |
|
| 84 | - ->where($query->expr()->eq('name', $query->createParameter('name'))) |
|
| 85 | - ->andWhere($query->expr()->eq('visibility', $query->createParameter('visibility'))) |
|
| 86 | - ->andWhere($query->expr()->eq('editable', $query->createParameter('editable'))); |
|
| 87 | - } |
|
| 88 | - |
|
| 89 | - /** |
|
| 90 | - * {@inheritdoc} |
|
| 91 | - */ |
|
| 92 | - public function getTagsByIds($tagIds): array { |
|
| 93 | - if (!\is_array($tagIds)) { |
|
| 94 | - $tagIds = [$tagIds]; |
|
| 95 | - } |
|
| 96 | - |
|
| 97 | - $tags = []; |
|
| 98 | - |
|
| 99 | - // note: not all databases will fail if it's a string or starts with a number |
|
| 100 | - foreach ($tagIds as $tagId) { |
|
| 101 | - if (!is_numeric($tagId)) { |
|
| 102 | - throw new \InvalidArgumentException('Tag id must be integer'); |
|
| 103 | - } |
|
| 104 | - } |
|
| 105 | - |
|
| 106 | - $query = $this->connection->getQueryBuilder(); |
|
| 107 | - $query->select('*') |
|
| 108 | - ->from(self::TAG_TABLE) |
|
| 109 | - ->where($query->expr()->in('id', $query->createParameter('tagids'))) |
|
| 110 | - ->addOrderBy('name', 'ASC') |
|
| 111 | - ->addOrderBy('visibility', 'ASC') |
|
| 112 | - ->addOrderBy('editable', 'ASC') |
|
| 113 | - ->setParameter('tagids', $tagIds, IQueryBuilder::PARAM_INT_ARRAY); |
|
| 114 | - |
|
| 115 | - $result = $query->execute(); |
|
| 116 | - while ($row = $result->fetch()) { |
|
| 117 | - $tags[$row['id']] = $this->createSystemTagFromRow($row); |
|
| 118 | - } |
|
| 119 | - |
|
| 120 | - $result->closeCursor(); |
|
| 121 | - |
|
| 122 | - if (\count($tags) !== \count($tagIds)) { |
|
| 123 | - throw new TagNotFoundException( |
|
| 124 | - 'Tag id(s) not found', 0, null, array_diff($tagIds, array_keys($tags)) |
|
| 125 | - ); |
|
| 126 | - } |
|
| 127 | - |
|
| 128 | - return $tags; |
|
| 129 | - } |
|
| 130 | - |
|
| 131 | - /** |
|
| 132 | - * {@inheritdoc} |
|
| 133 | - */ |
|
| 134 | - public function getAllTags($visibilityFilter = null, $nameSearchPattern = null): array { |
|
| 135 | - $tags = []; |
|
| 136 | - |
|
| 137 | - $query = $this->connection->getQueryBuilder(); |
|
| 138 | - $query->select('*') |
|
| 139 | - ->from(self::TAG_TABLE); |
|
| 140 | - |
|
| 141 | - if (!\is_null($visibilityFilter)) { |
|
| 142 | - $query->andWhere($query->expr()->eq('visibility', $query->createNamedParameter((int)$visibilityFilter))); |
|
| 143 | - } |
|
| 144 | - |
|
| 145 | - if (!empty($nameSearchPattern)) { |
|
| 146 | - $query->andWhere( |
|
| 147 | - $query->expr()->like( |
|
| 148 | - 'name', |
|
| 149 | - $query->createNamedParameter('%' . $this->connection->escapeLikeParameter($nameSearchPattern). '%') |
|
| 150 | - ) |
|
| 151 | - ); |
|
| 152 | - } |
|
| 153 | - |
|
| 154 | - $query |
|
| 155 | - ->addOrderBy('name', 'ASC') |
|
| 156 | - ->addOrderBy('visibility', 'ASC') |
|
| 157 | - ->addOrderBy('editable', 'ASC'); |
|
| 158 | - |
|
| 159 | - $result = $query->execute(); |
|
| 160 | - while ($row = $result->fetch()) { |
|
| 161 | - $tags[$row['id']] = $this->createSystemTagFromRow($row); |
|
| 162 | - } |
|
| 163 | - |
|
| 164 | - $result->closeCursor(); |
|
| 165 | - |
|
| 166 | - return $tags; |
|
| 167 | - } |
|
| 168 | - |
|
| 169 | - /** |
|
| 170 | - * {@inheritdoc} |
|
| 171 | - */ |
|
| 172 | - public function getTag(string $tagName, bool $userVisible, bool $userAssignable): ISystemTag { |
|
| 173 | - $result = $this->selectTagQuery |
|
| 174 | - ->setParameter('name', $tagName) |
|
| 175 | - ->setParameter('visibility', $userVisible ? 1 : 0) |
|
| 176 | - ->setParameter('editable', $userAssignable ? 1 : 0) |
|
| 177 | - ->execute(); |
|
| 178 | - |
|
| 179 | - $row = $result->fetch(); |
|
| 180 | - $result->closeCursor(); |
|
| 181 | - if (!$row) { |
|
| 182 | - throw new TagNotFoundException( |
|
| 183 | - 'Tag ("' . $tagName . '", '. $userVisible . ', ' . $userAssignable . ') does not exist' |
|
| 184 | - ); |
|
| 185 | - } |
|
| 186 | - |
|
| 187 | - return $this->createSystemTagFromRow($row); |
|
| 188 | - } |
|
| 189 | - |
|
| 190 | - /** |
|
| 191 | - * {@inheritdoc} |
|
| 192 | - */ |
|
| 193 | - public function createTag(string $tagName, bool $userVisible, bool $userAssignable): ISystemTag { |
|
| 194 | - $query = $this->connection->getQueryBuilder(); |
|
| 195 | - $query->insert(self::TAG_TABLE) |
|
| 196 | - ->values([ |
|
| 197 | - 'name' => $query->createNamedParameter($tagName), |
|
| 198 | - 'visibility' => $query->createNamedParameter($userVisible ? 1 : 0), |
|
| 199 | - 'editable' => $query->createNamedParameter($userAssignable ? 1 : 0), |
|
| 200 | - ]); |
|
| 201 | - |
|
| 202 | - try { |
|
| 203 | - $query->execute(); |
|
| 204 | - } catch (UniqueConstraintViolationException $e) { |
|
| 205 | - throw new TagAlreadyExistsException( |
|
| 206 | - 'Tag ("' . $tagName . '", '. $userVisible . ', ' . $userAssignable . ') already exists', |
|
| 207 | - 0, |
|
| 208 | - $e |
|
| 209 | - ); |
|
| 210 | - } |
|
| 211 | - |
|
| 212 | - $tagId = $query->getLastInsertId(); |
|
| 213 | - |
|
| 214 | - $tag = new SystemTag( |
|
| 215 | - (string)$tagId, |
|
| 216 | - $tagName, |
|
| 217 | - $userVisible, |
|
| 218 | - $userAssignable |
|
| 219 | - ); |
|
| 220 | - |
|
| 221 | - $this->dispatcher->dispatch(ManagerEvent::EVENT_CREATE, new ManagerEvent( |
|
| 222 | - ManagerEvent::EVENT_CREATE, $tag |
|
| 223 | - )); |
|
| 224 | - |
|
| 225 | - return $tag; |
|
| 226 | - } |
|
| 227 | - |
|
| 228 | - /** |
|
| 229 | - * {@inheritdoc} |
|
| 230 | - */ |
|
| 231 | - public function updateTag(string $tagId, string $tagName, bool $userVisible, bool $userAssignable) { |
|
| 232 | - try { |
|
| 233 | - $tags = $this->getTagsByIds($tagId); |
|
| 234 | - } catch (TagNotFoundException $e) { |
|
| 235 | - throw new TagNotFoundException( |
|
| 236 | - 'Tag does not exist', 0, null, [$tagId] |
|
| 237 | - ); |
|
| 238 | - } |
|
| 239 | - |
|
| 240 | - $beforeUpdate = array_shift($tags); |
|
| 241 | - $afterUpdate = new SystemTag( |
|
| 242 | - $tagId, |
|
| 243 | - $tagName, |
|
| 244 | - $userVisible, |
|
| 245 | - $userAssignable |
|
| 246 | - ); |
|
| 247 | - |
|
| 248 | - $query = $this->connection->getQueryBuilder(); |
|
| 249 | - $query->update(self::TAG_TABLE) |
|
| 250 | - ->set('name', $query->createParameter('name')) |
|
| 251 | - ->set('visibility', $query->createParameter('visibility')) |
|
| 252 | - ->set('editable', $query->createParameter('editable')) |
|
| 253 | - ->where($query->expr()->eq('id', $query->createParameter('tagid'))) |
|
| 254 | - ->setParameter('name', $tagName) |
|
| 255 | - ->setParameter('visibility', $userVisible ? 1 : 0) |
|
| 256 | - ->setParameter('editable', $userAssignable ? 1 : 0) |
|
| 257 | - ->setParameter('tagid', $tagId); |
|
| 258 | - |
|
| 259 | - try { |
|
| 260 | - if ($query->execute() === 0) { |
|
| 261 | - throw new TagNotFoundException( |
|
| 262 | - 'Tag does not exist', 0, null, [$tagId] |
|
| 263 | - ); |
|
| 264 | - } |
|
| 265 | - } catch (UniqueConstraintViolationException $e) { |
|
| 266 | - throw new TagAlreadyExistsException( |
|
| 267 | - 'Tag ("' . $tagName . '", '. $userVisible . ', ' . $userAssignable . ') already exists', |
|
| 268 | - 0, |
|
| 269 | - $e |
|
| 270 | - ); |
|
| 271 | - } |
|
| 272 | - |
|
| 273 | - $this->dispatcher->dispatch(ManagerEvent::EVENT_UPDATE, new ManagerEvent( |
|
| 274 | - ManagerEvent::EVENT_UPDATE, $afterUpdate, $beforeUpdate |
|
| 275 | - )); |
|
| 276 | - } |
|
| 277 | - |
|
| 278 | - /** |
|
| 279 | - * {@inheritdoc} |
|
| 280 | - */ |
|
| 281 | - public function deleteTags($tagIds) { |
|
| 282 | - if (!\is_array($tagIds)) { |
|
| 283 | - $tagIds = [$tagIds]; |
|
| 284 | - } |
|
| 285 | - |
|
| 286 | - $tagNotFoundException = null; |
|
| 287 | - $tags = []; |
|
| 288 | - try { |
|
| 289 | - $tags = $this->getTagsByIds($tagIds); |
|
| 290 | - } catch (TagNotFoundException $e) { |
|
| 291 | - $tagNotFoundException = $e; |
|
| 292 | - |
|
| 293 | - // Get existing tag objects for the hooks later |
|
| 294 | - $existingTags = array_diff($tagIds, $tagNotFoundException->getMissingTags()); |
|
| 295 | - if (!empty($existingTags)) { |
|
| 296 | - try { |
|
| 297 | - $tags = $this->getTagsByIds($existingTags); |
|
| 298 | - } catch (TagNotFoundException $e) { |
|
| 299 | - // Ignore further errors... |
|
| 300 | - } |
|
| 301 | - } |
|
| 302 | - } |
|
| 303 | - |
|
| 304 | - // delete relationships first |
|
| 305 | - $query = $this->connection->getQueryBuilder(); |
|
| 306 | - $query->delete(SystemTagObjectMapper::RELATION_TABLE) |
|
| 307 | - ->where($query->expr()->in('systemtagid', $query->createParameter('tagids'))) |
|
| 308 | - ->setParameter('tagids', $tagIds, IQueryBuilder::PARAM_INT_ARRAY) |
|
| 309 | - ->execute(); |
|
| 310 | - |
|
| 311 | - $query = $this->connection->getQueryBuilder(); |
|
| 312 | - $query->delete(self::TAG_TABLE) |
|
| 313 | - ->where($query->expr()->in('id', $query->createParameter('tagids'))) |
|
| 314 | - ->setParameter('tagids', $tagIds, IQueryBuilder::PARAM_INT_ARRAY) |
|
| 315 | - ->execute(); |
|
| 316 | - |
|
| 317 | - foreach ($tags as $tag) { |
|
| 318 | - $this->dispatcher->dispatch(ManagerEvent::EVENT_DELETE, new ManagerEvent( |
|
| 319 | - ManagerEvent::EVENT_DELETE, $tag |
|
| 320 | - )); |
|
| 321 | - } |
|
| 322 | - |
|
| 323 | - if ($tagNotFoundException !== null) { |
|
| 324 | - throw new TagNotFoundException( |
|
| 325 | - 'Tag id(s) not found', 0, $tagNotFoundException, $tagNotFoundException->getMissingTags() |
|
| 326 | - ); |
|
| 327 | - } |
|
| 328 | - } |
|
| 329 | - |
|
| 330 | - /** |
|
| 331 | - * {@inheritdoc} |
|
| 332 | - */ |
|
| 333 | - public function canUserAssignTag(ISystemTag $tag, IUser $user): bool { |
|
| 334 | - // early check to avoid unneeded group lookups |
|
| 335 | - if ($tag->isUserAssignable() && $tag->isUserVisible()) { |
|
| 336 | - return true; |
|
| 337 | - } |
|
| 338 | - |
|
| 339 | - if ($this->groupManager->isAdmin($user->getUID())) { |
|
| 340 | - return true; |
|
| 341 | - } |
|
| 342 | - |
|
| 343 | - if (!$tag->isUserVisible()) { |
|
| 344 | - return false; |
|
| 345 | - } |
|
| 346 | - |
|
| 347 | - $groupIds = $this->groupManager->getUserGroupIds($user); |
|
| 348 | - if (!empty($groupIds)) { |
|
| 349 | - $matchingGroups = array_intersect($groupIds, $this->getTagGroups($tag)); |
|
| 350 | - if (!empty($matchingGroups)) { |
|
| 351 | - return true; |
|
| 352 | - } |
|
| 353 | - } |
|
| 354 | - |
|
| 355 | - return false; |
|
| 356 | - } |
|
| 357 | - |
|
| 358 | - /** |
|
| 359 | - * {@inheritdoc} |
|
| 360 | - */ |
|
| 361 | - public function canUserSeeTag(ISystemTag $tag, IUser $user): bool { |
|
| 362 | - if ($tag->isUserVisible()) { |
|
| 363 | - return true; |
|
| 364 | - } |
|
| 365 | - |
|
| 366 | - if ($this->groupManager->isAdmin($user->getUID())) { |
|
| 367 | - return true; |
|
| 368 | - } |
|
| 369 | - |
|
| 370 | - return false; |
|
| 371 | - } |
|
| 372 | - |
|
| 373 | - private function createSystemTagFromRow($row) { |
|
| 374 | - return new SystemTag((string)$row['id'], $row['name'], (bool)$row['visibility'], (bool)$row['editable']); |
|
| 375 | - } |
|
| 376 | - |
|
| 377 | - /** |
|
| 378 | - * {@inheritdoc} |
|
| 379 | - */ |
|
| 380 | - public function setTagGroups(ISystemTag $tag, array $groupIds) { |
|
| 381 | - // delete relationships first |
|
| 382 | - $this->connection->beginTransaction(); |
|
| 383 | - try { |
|
| 384 | - $query = $this->connection->getQueryBuilder(); |
|
| 385 | - $query->delete(self::TAG_GROUP_TABLE) |
|
| 386 | - ->where($query->expr()->eq('systemtagid', $query->createNamedParameter($tag->getId()))) |
|
| 387 | - ->execute(); |
|
| 388 | - |
|
| 389 | - // add each group id |
|
| 390 | - $query = $this->connection->getQueryBuilder(); |
|
| 391 | - $query->insert(self::TAG_GROUP_TABLE) |
|
| 392 | - ->values([ |
|
| 393 | - 'systemtagid' => $query->createNamedParameter($tag->getId()), |
|
| 394 | - 'gid' => $query->createParameter('gid'), |
|
| 395 | - ]); |
|
| 396 | - foreach ($groupIds as $groupId) { |
|
| 397 | - if ($groupId === '') { |
|
| 398 | - continue; |
|
| 399 | - } |
|
| 400 | - $query->setParameter('gid', $groupId); |
|
| 401 | - $query->execute(); |
|
| 402 | - } |
|
| 403 | - |
|
| 404 | - $this->connection->commit(); |
|
| 405 | - } catch (\Exception $e) { |
|
| 406 | - $this->connection->rollBack(); |
|
| 407 | - throw $e; |
|
| 408 | - } |
|
| 409 | - } |
|
| 410 | - |
|
| 411 | - /** |
|
| 412 | - * {@inheritdoc} |
|
| 413 | - */ |
|
| 414 | - public function getTagGroups(ISystemTag $tag): array { |
|
| 415 | - $groupIds = []; |
|
| 416 | - $query = $this->connection->getQueryBuilder(); |
|
| 417 | - $query->select('gid') |
|
| 418 | - ->from(self::TAG_GROUP_TABLE) |
|
| 419 | - ->where($query->expr()->eq('systemtagid', $query->createNamedParameter($tag->getId()))) |
|
| 420 | - ->orderBy('gid'); |
|
| 421 | - |
|
| 422 | - $result = $query->execute(); |
|
| 423 | - while ($row = $result->fetch()) { |
|
| 424 | - $groupIds[] = $row['gid']; |
|
| 425 | - } |
|
| 426 | - |
|
| 427 | - $result->closeCursor(); |
|
| 428 | - |
|
| 429 | - return $groupIds; |
|
| 430 | - } |
|
| 46 | + const TAG_TABLE = 'systemtag'; |
|
| 47 | + const TAG_GROUP_TABLE = 'systemtag_group'; |
|
| 48 | + |
|
| 49 | + /** @var IDBConnection */ |
|
| 50 | + protected $connection; |
|
| 51 | + |
|
| 52 | + /** @var EventDispatcherInterface */ |
|
| 53 | + protected $dispatcher; |
|
| 54 | + |
|
| 55 | + /** @var IGroupManager */ |
|
| 56 | + protected $groupManager; |
|
| 57 | + |
|
| 58 | + /** |
|
| 59 | + * Prepared query for selecting tags directly |
|
| 60 | + * |
|
| 61 | + * @var \OCP\DB\QueryBuilder\IQueryBuilder |
|
| 62 | + */ |
|
| 63 | + private $selectTagQuery; |
|
| 64 | + |
|
| 65 | + /** |
|
| 66 | + * Constructor. |
|
| 67 | + * |
|
| 68 | + * @param IDBConnection $connection database connection |
|
| 69 | + * @param IGroupManager $groupManager |
|
| 70 | + * @param EventDispatcherInterface $dispatcher |
|
| 71 | + */ |
|
| 72 | + public function __construct( |
|
| 73 | + IDBConnection $connection, |
|
| 74 | + IGroupManager $groupManager, |
|
| 75 | + EventDispatcherInterface $dispatcher |
|
| 76 | + ) { |
|
| 77 | + $this->connection = $connection; |
|
| 78 | + $this->groupManager = $groupManager; |
|
| 79 | + $this->dispatcher = $dispatcher; |
|
| 80 | + |
|
| 81 | + $query = $this->connection->getQueryBuilder(); |
|
| 82 | + $this->selectTagQuery = $query->select('*') |
|
| 83 | + ->from(self::TAG_TABLE) |
|
| 84 | + ->where($query->expr()->eq('name', $query->createParameter('name'))) |
|
| 85 | + ->andWhere($query->expr()->eq('visibility', $query->createParameter('visibility'))) |
|
| 86 | + ->andWhere($query->expr()->eq('editable', $query->createParameter('editable'))); |
|
| 87 | + } |
|
| 88 | + |
|
| 89 | + /** |
|
| 90 | + * {@inheritdoc} |
|
| 91 | + */ |
|
| 92 | + public function getTagsByIds($tagIds): array { |
|
| 93 | + if (!\is_array($tagIds)) { |
|
| 94 | + $tagIds = [$tagIds]; |
|
| 95 | + } |
|
| 96 | + |
|
| 97 | + $tags = []; |
|
| 98 | + |
|
| 99 | + // note: not all databases will fail if it's a string or starts with a number |
|
| 100 | + foreach ($tagIds as $tagId) { |
|
| 101 | + if (!is_numeric($tagId)) { |
|
| 102 | + throw new \InvalidArgumentException('Tag id must be integer'); |
|
| 103 | + } |
|
| 104 | + } |
|
| 105 | + |
|
| 106 | + $query = $this->connection->getQueryBuilder(); |
|
| 107 | + $query->select('*') |
|
| 108 | + ->from(self::TAG_TABLE) |
|
| 109 | + ->where($query->expr()->in('id', $query->createParameter('tagids'))) |
|
| 110 | + ->addOrderBy('name', 'ASC') |
|
| 111 | + ->addOrderBy('visibility', 'ASC') |
|
| 112 | + ->addOrderBy('editable', 'ASC') |
|
| 113 | + ->setParameter('tagids', $tagIds, IQueryBuilder::PARAM_INT_ARRAY); |
|
| 114 | + |
|
| 115 | + $result = $query->execute(); |
|
| 116 | + while ($row = $result->fetch()) { |
|
| 117 | + $tags[$row['id']] = $this->createSystemTagFromRow($row); |
|
| 118 | + } |
|
| 119 | + |
|
| 120 | + $result->closeCursor(); |
|
| 121 | + |
|
| 122 | + if (\count($tags) !== \count($tagIds)) { |
|
| 123 | + throw new TagNotFoundException( |
|
| 124 | + 'Tag id(s) not found', 0, null, array_diff($tagIds, array_keys($tags)) |
|
| 125 | + ); |
|
| 126 | + } |
|
| 127 | + |
|
| 128 | + return $tags; |
|
| 129 | + } |
|
| 130 | + |
|
| 131 | + /** |
|
| 132 | + * {@inheritdoc} |
|
| 133 | + */ |
|
| 134 | + public function getAllTags($visibilityFilter = null, $nameSearchPattern = null): array { |
|
| 135 | + $tags = []; |
|
| 136 | + |
|
| 137 | + $query = $this->connection->getQueryBuilder(); |
|
| 138 | + $query->select('*') |
|
| 139 | + ->from(self::TAG_TABLE); |
|
| 140 | + |
|
| 141 | + if (!\is_null($visibilityFilter)) { |
|
| 142 | + $query->andWhere($query->expr()->eq('visibility', $query->createNamedParameter((int)$visibilityFilter))); |
|
| 143 | + } |
|
| 144 | + |
|
| 145 | + if (!empty($nameSearchPattern)) { |
|
| 146 | + $query->andWhere( |
|
| 147 | + $query->expr()->like( |
|
| 148 | + 'name', |
|
| 149 | + $query->createNamedParameter('%' . $this->connection->escapeLikeParameter($nameSearchPattern). '%') |
|
| 150 | + ) |
|
| 151 | + ); |
|
| 152 | + } |
|
| 153 | + |
|
| 154 | + $query |
|
| 155 | + ->addOrderBy('name', 'ASC') |
|
| 156 | + ->addOrderBy('visibility', 'ASC') |
|
| 157 | + ->addOrderBy('editable', 'ASC'); |
|
| 158 | + |
|
| 159 | + $result = $query->execute(); |
|
| 160 | + while ($row = $result->fetch()) { |
|
| 161 | + $tags[$row['id']] = $this->createSystemTagFromRow($row); |
|
| 162 | + } |
|
| 163 | + |
|
| 164 | + $result->closeCursor(); |
|
| 165 | + |
|
| 166 | + return $tags; |
|
| 167 | + } |
|
| 168 | + |
|
| 169 | + /** |
|
| 170 | + * {@inheritdoc} |
|
| 171 | + */ |
|
| 172 | + public function getTag(string $tagName, bool $userVisible, bool $userAssignable): ISystemTag { |
|
| 173 | + $result = $this->selectTagQuery |
|
| 174 | + ->setParameter('name', $tagName) |
|
| 175 | + ->setParameter('visibility', $userVisible ? 1 : 0) |
|
| 176 | + ->setParameter('editable', $userAssignable ? 1 : 0) |
|
| 177 | + ->execute(); |
|
| 178 | + |
|
| 179 | + $row = $result->fetch(); |
|
| 180 | + $result->closeCursor(); |
|
| 181 | + if (!$row) { |
|
| 182 | + throw new TagNotFoundException( |
|
| 183 | + 'Tag ("' . $tagName . '", '. $userVisible . ', ' . $userAssignable . ') does not exist' |
|
| 184 | + ); |
|
| 185 | + } |
|
| 186 | + |
|
| 187 | + return $this->createSystemTagFromRow($row); |
|
| 188 | + } |
|
| 189 | + |
|
| 190 | + /** |
|
| 191 | + * {@inheritdoc} |
|
| 192 | + */ |
|
| 193 | + public function createTag(string $tagName, bool $userVisible, bool $userAssignable): ISystemTag { |
|
| 194 | + $query = $this->connection->getQueryBuilder(); |
|
| 195 | + $query->insert(self::TAG_TABLE) |
|
| 196 | + ->values([ |
|
| 197 | + 'name' => $query->createNamedParameter($tagName), |
|
| 198 | + 'visibility' => $query->createNamedParameter($userVisible ? 1 : 0), |
|
| 199 | + 'editable' => $query->createNamedParameter($userAssignable ? 1 : 0), |
|
| 200 | + ]); |
|
| 201 | + |
|
| 202 | + try { |
|
| 203 | + $query->execute(); |
|
| 204 | + } catch (UniqueConstraintViolationException $e) { |
|
| 205 | + throw new TagAlreadyExistsException( |
|
| 206 | + 'Tag ("' . $tagName . '", '. $userVisible . ', ' . $userAssignable . ') already exists', |
|
| 207 | + 0, |
|
| 208 | + $e |
|
| 209 | + ); |
|
| 210 | + } |
|
| 211 | + |
|
| 212 | + $tagId = $query->getLastInsertId(); |
|
| 213 | + |
|
| 214 | + $tag = new SystemTag( |
|
| 215 | + (string)$tagId, |
|
| 216 | + $tagName, |
|
| 217 | + $userVisible, |
|
| 218 | + $userAssignable |
|
| 219 | + ); |
|
| 220 | + |
|
| 221 | + $this->dispatcher->dispatch(ManagerEvent::EVENT_CREATE, new ManagerEvent( |
|
| 222 | + ManagerEvent::EVENT_CREATE, $tag |
|
| 223 | + )); |
|
| 224 | + |
|
| 225 | + return $tag; |
|
| 226 | + } |
|
| 227 | + |
|
| 228 | + /** |
|
| 229 | + * {@inheritdoc} |
|
| 230 | + */ |
|
| 231 | + public function updateTag(string $tagId, string $tagName, bool $userVisible, bool $userAssignable) { |
|
| 232 | + try { |
|
| 233 | + $tags = $this->getTagsByIds($tagId); |
|
| 234 | + } catch (TagNotFoundException $e) { |
|
| 235 | + throw new TagNotFoundException( |
|
| 236 | + 'Tag does not exist', 0, null, [$tagId] |
|
| 237 | + ); |
|
| 238 | + } |
|
| 239 | + |
|
| 240 | + $beforeUpdate = array_shift($tags); |
|
| 241 | + $afterUpdate = new SystemTag( |
|
| 242 | + $tagId, |
|
| 243 | + $tagName, |
|
| 244 | + $userVisible, |
|
| 245 | + $userAssignable |
|
| 246 | + ); |
|
| 247 | + |
|
| 248 | + $query = $this->connection->getQueryBuilder(); |
|
| 249 | + $query->update(self::TAG_TABLE) |
|
| 250 | + ->set('name', $query->createParameter('name')) |
|
| 251 | + ->set('visibility', $query->createParameter('visibility')) |
|
| 252 | + ->set('editable', $query->createParameter('editable')) |
|
| 253 | + ->where($query->expr()->eq('id', $query->createParameter('tagid'))) |
|
| 254 | + ->setParameter('name', $tagName) |
|
| 255 | + ->setParameter('visibility', $userVisible ? 1 : 0) |
|
| 256 | + ->setParameter('editable', $userAssignable ? 1 : 0) |
|
| 257 | + ->setParameter('tagid', $tagId); |
|
| 258 | + |
|
| 259 | + try { |
|
| 260 | + if ($query->execute() === 0) { |
|
| 261 | + throw new TagNotFoundException( |
|
| 262 | + 'Tag does not exist', 0, null, [$tagId] |
|
| 263 | + ); |
|
| 264 | + } |
|
| 265 | + } catch (UniqueConstraintViolationException $e) { |
|
| 266 | + throw new TagAlreadyExistsException( |
|
| 267 | + 'Tag ("' . $tagName . '", '. $userVisible . ', ' . $userAssignable . ') already exists', |
|
| 268 | + 0, |
|
| 269 | + $e |
|
| 270 | + ); |
|
| 271 | + } |
|
| 272 | + |
|
| 273 | + $this->dispatcher->dispatch(ManagerEvent::EVENT_UPDATE, new ManagerEvent( |
|
| 274 | + ManagerEvent::EVENT_UPDATE, $afterUpdate, $beforeUpdate |
|
| 275 | + )); |
|
| 276 | + } |
|
| 277 | + |
|
| 278 | + /** |
|
| 279 | + * {@inheritdoc} |
|
| 280 | + */ |
|
| 281 | + public function deleteTags($tagIds) { |
|
| 282 | + if (!\is_array($tagIds)) { |
|
| 283 | + $tagIds = [$tagIds]; |
|
| 284 | + } |
|
| 285 | + |
|
| 286 | + $tagNotFoundException = null; |
|
| 287 | + $tags = []; |
|
| 288 | + try { |
|
| 289 | + $tags = $this->getTagsByIds($tagIds); |
|
| 290 | + } catch (TagNotFoundException $e) { |
|
| 291 | + $tagNotFoundException = $e; |
|
| 292 | + |
|
| 293 | + // Get existing tag objects for the hooks later |
|
| 294 | + $existingTags = array_diff($tagIds, $tagNotFoundException->getMissingTags()); |
|
| 295 | + if (!empty($existingTags)) { |
|
| 296 | + try { |
|
| 297 | + $tags = $this->getTagsByIds($existingTags); |
|
| 298 | + } catch (TagNotFoundException $e) { |
|
| 299 | + // Ignore further errors... |
|
| 300 | + } |
|
| 301 | + } |
|
| 302 | + } |
|
| 303 | + |
|
| 304 | + // delete relationships first |
|
| 305 | + $query = $this->connection->getQueryBuilder(); |
|
| 306 | + $query->delete(SystemTagObjectMapper::RELATION_TABLE) |
|
| 307 | + ->where($query->expr()->in('systemtagid', $query->createParameter('tagids'))) |
|
| 308 | + ->setParameter('tagids', $tagIds, IQueryBuilder::PARAM_INT_ARRAY) |
|
| 309 | + ->execute(); |
|
| 310 | + |
|
| 311 | + $query = $this->connection->getQueryBuilder(); |
|
| 312 | + $query->delete(self::TAG_TABLE) |
|
| 313 | + ->where($query->expr()->in('id', $query->createParameter('tagids'))) |
|
| 314 | + ->setParameter('tagids', $tagIds, IQueryBuilder::PARAM_INT_ARRAY) |
|
| 315 | + ->execute(); |
|
| 316 | + |
|
| 317 | + foreach ($tags as $tag) { |
|
| 318 | + $this->dispatcher->dispatch(ManagerEvent::EVENT_DELETE, new ManagerEvent( |
|
| 319 | + ManagerEvent::EVENT_DELETE, $tag |
|
| 320 | + )); |
|
| 321 | + } |
|
| 322 | + |
|
| 323 | + if ($tagNotFoundException !== null) { |
|
| 324 | + throw new TagNotFoundException( |
|
| 325 | + 'Tag id(s) not found', 0, $tagNotFoundException, $tagNotFoundException->getMissingTags() |
|
| 326 | + ); |
|
| 327 | + } |
|
| 328 | + } |
|
| 329 | + |
|
| 330 | + /** |
|
| 331 | + * {@inheritdoc} |
|
| 332 | + */ |
|
| 333 | + public function canUserAssignTag(ISystemTag $tag, IUser $user): bool { |
|
| 334 | + // early check to avoid unneeded group lookups |
|
| 335 | + if ($tag->isUserAssignable() && $tag->isUserVisible()) { |
|
| 336 | + return true; |
|
| 337 | + } |
|
| 338 | + |
|
| 339 | + if ($this->groupManager->isAdmin($user->getUID())) { |
|
| 340 | + return true; |
|
| 341 | + } |
|
| 342 | + |
|
| 343 | + if (!$tag->isUserVisible()) { |
|
| 344 | + return false; |
|
| 345 | + } |
|
| 346 | + |
|
| 347 | + $groupIds = $this->groupManager->getUserGroupIds($user); |
|
| 348 | + if (!empty($groupIds)) { |
|
| 349 | + $matchingGroups = array_intersect($groupIds, $this->getTagGroups($tag)); |
|
| 350 | + if (!empty($matchingGroups)) { |
|
| 351 | + return true; |
|
| 352 | + } |
|
| 353 | + } |
|
| 354 | + |
|
| 355 | + return false; |
|
| 356 | + } |
|
| 357 | + |
|
| 358 | + /** |
|
| 359 | + * {@inheritdoc} |
|
| 360 | + */ |
|
| 361 | + public function canUserSeeTag(ISystemTag $tag, IUser $user): bool { |
|
| 362 | + if ($tag->isUserVisible()) { |
|
| 363 | + return true; |
|
| 364 | + } |
|
| 365 | + |
|
| 366 | + if ($this->groupManager->isAdmin($user->getUID())) { |
|
| 367 | + return true; |
|
| 368 | + } |
|
| 369 | + |
|
| 370 | + return false; |
|
| 371 | + } |
|
| 372 | + |
|
| 373 | + private function createSystemTagFromRow($row) { |
|
| 374 | + return new SystemTag((string)$row['id'], $row['name'], (bool)$row['visibility'], (bool)$row['editable']); |
|
| 375 | + } |
|
| 376 | + |
|
| 377 | + /** |
|
| 378 | + * {@inheritdoc} |
|
| 379 | + */ |
|
| 380 | + public function setTagGroups(ISystemTag $tag, array $groupIds) { |
|
| 381 | + // delete relationships first |
|
| 382 | + $this->connection->beginTransaction(); |
|
| 383 | + try { |
|
| 384 | + $query = $this->connection->getQueryBuilder(); |
|
| 385 | + $query->delete(self::TAG_GROUP_TABLE) |
|
| 386 | + ->where($query->expr()->eq('systemtagid', $query->createNamedParameter($tag->getId()))) |
|
| 387 | + ->execute(); |
|
| 388 | + |
|
| 389 | + // add each group id |
|
| 390 | + $query = $this->connection->getQueryBuilder(); |
|
| 391 | + $query->insert(self::TAG_GROUP_TABLE) |
|
| 392 | + ->values([ |
|
| 393 | + 'systemtagid' => $query->createNamedParameter($tag->getId()), |
|
| 394 | + 'gid' => $query->createParameter('gid'), |
|
| 395 | + ]); |
|
| 396 | + foreach ($groupIds as $groupId) { |
|
| 397 | + if ($groupId === '') { |
|
| 398 | + continue; |
|
| 399 | + } |
|
| 400 | + $query->setParameter('gid', $groupId); |
|
| 401 | + $query->execute(); |
|
| 402 | + } |
|
| 403 | + |
|
| 404 | + $this->connection->commit(); |
|
| 405 | + } catch (\Exception $e) { |
|
| 406 | + $this->connection->rollBack(); |
|
| 407 | + throw $e; |
|
| 408 | + } |
|
| 409 | + } |
|
| 410 | + |
|
| 411 | + /** |
|
| 412 | + * {@inheritdoc} |
|
| 413 | + */ |
|
| 414 | + public function getTagGroups(ISystemTag $tag): array { |
|
| 415 | + $groupIds = []; |
|
| 416 | + $query = $this->connection->getQueryBuilder(); |
|
| 417 | + $query->select('gid') |
|
| 418 | + ->from(self::TAG_GROUP_TABLE) |
|
| 419 | + ->where($query->expr()->eq('systemtagid', $query->createNamedParameter($tag->getId()))) |
|
| 420 | + ->orderBy('gid'); |
|
| 421 | + |
|
| 422 | + $result = $query->execute(); |
|
| 423 | + while ($row = $result->fetch()) { |
|
| 424 | + $groupIds[] = $row['gid']; |
|
| 425 | + } |
|
| 426 | + |
|
| 427 | + $result->closeCursor(); |
|
| 428 | + |
|
| 429 | + return $groupIds; |
|
| 430 | + } |
|
| 431 | 431 | } |
@@ -28,66 +28,66 @@ |
||
| 28 | 28 | |
| 29 | 29 | class SystemTag implements ISystemTag { |
| 30 | 30 | |
| 31 | - /** |
|
| 32 | - * @var string |
|
| 33 | - */ |
|
| 34 | - private $id; |
|
| 31 | + /** |
|
| 32 | + * @var string |
|
| 33 | + */ |
|
| 34 | + private $id; |
|
| 35 | 35 | |
| 36 | - /** |
|
| 37 | - * @var string |
|
| 38 | - */ |
|
| 39 | - private $name; |
|
| 36 | + /** |
|
| 37 | + * @var string |
|
| 38 | + */ |
|
| 39 | + private $name; |
|
| 40 | 40 | |
| 41 | - /** |
|
| 42 | - * @var bool |
|
| 43 | - */ |
|
| 44 | - private $userVisible; |
|
| 41 | + /** |
|
| 42 | + * @var bool |
|
| 43 | + */ |
|
| 44 | + private $userVisible; |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * @var bool |
|
| 48 | - */ |
|
| 49 | - private $userAssignable; |
|
| 46 | + /** |
|
| 47 | + * @var bool |
|
| 48 | + */ |
|
| 49 | + private $userAssignable; |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * Constructor. |
|
| 53 | - * |
|
| 54 | - * @param string $id tag id |
|
| 55 | - * @param string $name tag name |
|
| 56 | - * @param bool $userVisible whether the tag is user visible |
|
| 57 | - * @param bool $userAssignable whether the tag is user assignable |
|
| 58 | - */ |
|
| 59 | - public function __construct(string $id, string $name, bool $userVisible, bool $userAssignable) { |
|
| 60 | - $this->id = $id; |
|
| 61 | - $this->name = $name; |
|
| 62 | - $this->userVisible = $userVisible; |
|
| 63 | - $this->userAssignable = $userAssignable; |
|
| 64 | - } |
|
| 51 | + /** |
|
| 52 | + * Constructor. |
|
| 53 | + * |
|
| 54 | + * @param string $id tag id |
|
| 55 | + * @param string $name tag name |
|
| 56 | + * @param bool $userVisible whether the tag is user visible |
|
| 57 | + * @param bool $userAssignable whether the tag is user assignable |
|
| 58 | + */ |
|
| 59 | + public function __construct(string $id, string $name, bool $userVisible, bool $userAssignable) { |
|
| 60 | + $this->id = $id; |
|
| 61 | + $this->name = $name; |
|
| 62 | + $this->userVisible = $userVisible; |
|
| 63 | + $this->userAssignable = $userAssignable; |
|
| 64 | + } |
|
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * {@inheritdoc} |
|
| 68 | - */ |
|
| 69 | - public function getId(): string { |
|
| 70 | - return $this->id; |
|
| 71 | - } |
|
| 66 | + /** |
|
| 67 | + * {@inheritdoc} |
|
| 68 | + */ |
|
| 69 | + public function getId(): string { |
|
| 70 | + return $this->id; |
|
| 71 | + } |
|
| 72 | 72 | |
| 73 | - /** |
|
| 74 | - * {@inheritdoc} |
|
| 75 | - */ |
|
| 76 | - public function getName(): string { |
|
| 77 | - return $this->name; |
|
| 78 | - } |
|
| 73 | + /** |
|
| 74 | + * {@inheritdoc} |
|
| 75 | + */ |
|
| 76 | + public function getName(): string { |
|
| 77 | + return $this->name; |
|
| 78 | + } |
|
| 79 | 79 | |
| 80 | - /** |
|
| 81 | - * {@inheritdoc} |
|
| 82 | - */ |
|
| 83 | - public function isUserVisible(): bool { |
|
| 84 | - return $this->userVisible; |
|
| 85 | - } |
|
| 80 | + /** |
|
| 81 | + * {@inheritdoc} |
|
| 82 | + */ |
|
| 83 | + public function isUserVisible(): bool { |
|
| 84 | + return $this->userVisible; |
|
| 85 | + } |
|
| 86 | 86 | |
| 87 | - /** |
|
| 88 | - * {@inheritdoc} |
|
| 89 | - */ |
|
| 90 | - public function isUserAssignable(): bool { |
|
| 91 | - return $this->userAssignable; |
|
| 92 | - } |
|
| 87 | + /** |
|
| 88 | + * {@inheritdoc} |
|
| 89 | + */ |
|
| 90 | + public function isUserAssignable(): bool { |
|
| 91 | + return $this->userAssignable; |
|
| 92 | + } |
|
| 93 | 93 | } |
@@ -36,48 +36,48 @@ |
||
| 36 | 36 | */ |
| 37 | 37 | class ManagerFactory implements ISystemTagManagerFactory { |
| 38 | 38 | |
| 39 | - /** |
|
| 40 | - * Server container |
|
| 41 | - * |
|
| 42 | - * @var IServerContainer |
|
| 43 | - */ |
|
| 44 | - private $serverContainer; |
|
| 39 | + /** |
|
| 40 | + * Server container |
|
| 41 | + * |
|
| 42 | + * @var IServerContainer |
|
| 43 | + */ |
|
| 44 | + private $serverContainer; |
|
| 45 | 45 | |
| 46 | - /** |
|
| 47 | - * Constructor for the system tag manager factory |
|
| 48 | - * |
|
| 49 | - * @param IServerContainer $serverContainer server container |
|
| 50 | - */ |
|
| 51 | - public function __construct(IServerContainer $serverContainer) { |
|
| 52 | - $this->serverContainer = $serverContainer; |
|
| 53 | - } |
|
| 46 | + /** |
|
| 47 | + * Constructor for the system tag manager factory |
|
| 48 | + * |
|
| 49 | + * @param IServerContainer $serverContainer server container |
|
| 50 | + */ |
|
| 51 | + public function __construct(IServerContainer $serverContainer) { |
|
| 52 | + $this->serverContainer = $serverContainer; |
|
| 53 | + } |
|
| 54 | 54 | |
| 55 | - /** |
|
| 56 | - * Creates and returns an instance of the system tag manager |
|
| 57 | - * |
|
| 58 | - * @return ISystemTagManager |
|
| 59 | - * @since 9.0.0 |
|
| 60 | - */ |
|
| 61 | - public function getManager(): ISystemTagManager { |
|
| 62 | - return new SystemTagManager( |
|
| 63 | - $this->serverContainer->getDatabaseConnection(), |
|
| 64 | - $this->serverContainer->getGroupManager(), |
|
| 65 | - $this->serverContainer->getEventDispatcher() |
|
| 66 | - ); |
|
| 67 | - } |
|
| 55 | + /** |
|
| 56 | + * Creates and returns an instance of the system tag manager |
|
| 57 | + * |
|
| 58 | + * @return ISystemTagManager |
|
| 59 | + * @since 9.0.0 |
|
| 60 | + */ |
|
| 61 | + public function getManager(): ISystemTagManager { |
|
| 62 | + return new SystemTagManager( |
|
| 63 | + $this->serverContainer->getDatabaseConnection(), |
|
| 64 | + $this->serverContainer->getGroupManager(), |
|
| 65 | + $this->serverContainer->getEventDispatcher() |
|
| 66 | + ); |
|
| 67 | + } |
|
| 68 | 68 | |
| 69 | - /** |
|
| 70 | - * Creates and returns an instance of the system tag object |
|
| 71 | - * mapper |
|
| 72 | - * |
|
| 73 | - * @return ISystemTagObjectMapper |
|
| 74 | - * @since 9.0.0 |
|
| 75 | - */ |
|
| 76 | - public function getObjectMapper(): ISystemTagObjectMapper { |
|
| 77 | - return new SystemTagObjectMapper( |
|
| 78 | - $this->serverContainer->getDatabaseConnection(), |
|
| 79 | - $this->getManager(), |
|
| 80 | - $this->serverContainer->getEventDispatcher() |
|
| 81 | - ); |
|
| 82 | - } |
|
| 69 | + /** |
|
| 70 | + * Creates and returns an instance of the system tag object |
|
| 71 | + * mapper |
|
| 72 | + * |
|
| 73 | + * @return ISystemTagObjectMapper |
|
| 74 | + * @since 9.0.0 |
|
| 75 | + */ |
|
| 76 | + public function getObjectMapper(): ISystemTagObjectMapper { |
|
| 77 | + return new SystemTagObjectMapper( |
|
| 78 | + $this->serverContainer->getDatabaseConnection(), |
|
| 79 | + $this->getManager(), |
|
| 80 | + $this->serverContainer->getEventDispatcher() |
|
| 81 | + ); |
|
| 82 | + } |
|
| 83 | 83 | } |
@@ -31,19 +31,19 @@ |
||
| 31 | 31 | */ |
| 32 | 32 | class OpenStackV3 extends AuthMechanism { |
| 33 | 33 | |
| 34 | - public function __construct(IL10N $l) { |
|
| 35 | - $this |
|
| 36 | - ->setIdentifier('openstack::openstackv3') |
|
| 37 | - ->setScheme(self::SCHEME_OPENSTACK) |
|
| 38 | - ->setText($l->t('OpenStack v3')) |
|
| 39 | - ->addParameters([ |
|
| 40 | - new DefinitionParameter('user', $l->t('Username')), |
|
| 41 | - new DefinitionParameter('domain', $l->t('Domain')), |
|
| 42 | - (new DefinitionParameter('password', $l->t('Password'))) |
|
| 43 | - ->setType(DefinitionParameter::VALUE_PASSWORD), |
|
| 44 | - new DefinitionParameter('url', $l->t('Identity endpoint URL')) |
|
| 45 | - ]) |
|
| 46 | - ; |
|
| 47 | - } |
|
| 34 | + public function __construct(IL10N $l) { |
|
| 35 | + $this |
|
| 36 | + ->setIdentifier('openstack::openstackv3') |
|
| 37 | + ->setScheme(self::SCHEME_OPENSTACK) |
|
| 38 | + ->setText($l->t('OpenStack v3')) |
|
| 39 | + ->addParameters([ |
|
| 40 | + new DefinitionParameter('user', $l->t('Username')), |
|
| 41 | + new DefinitionParameter('domain', $l->t('Domain')), |
|
| 42 | + (new DefinitionParameter('password', $l->t('Password'))) |
|
| 43 | + ->setType(DefinitionParameter::VALUE_PASSWORD), |
|
| 44 | + new DefinitionParameter('url', $l->t('Identity endpoint URL')) |
|
| 45 | + ]) |
|
| 46 | + ; |
|
| 47 | + } |
|
| 48 | 48 | |
| 49 | 49 | } |