Nextcloud PHP API (stable18)

ISystemTagObjectMapper

Public interface to access and manage system-wide tags.

Tags
since
9.0.0

Table of Contents

assignTags()  : mixed
Assign the given tags to the given object.
getObjectIdsForTags()  : string[]
Get a list of objects tagged with $tagIds.
getTagIdsForObjects()  : array
Get a list of tag ids for the given object ids.
haveTag()  : bool
Checks whether the given objects have the given tag.
unassignTags()  : mixed
Unassign the given tags from the given object.

Methods

assignTags()

Assign the given tags to the given object.

public assignTags(string $objId, string $objectType, string|array $tagIds) : mixed

If at least one of the given tag ids doesn't exist, none of the tags will be assigned.

If the relationship already existed, fail silently.

Parameters
$objId : string

object id

$objectType : string

object type

$tagIds : string|array

tag id or array of tag ids to assign

Tags
throws
TagNotFoundException

if at least one of the given tags does not exist

since
9.0.0
Return values
mixed

getObjectIdsForTags()

Get a list of objects tagged with $tagIds.

public getObjectIdsForTags(string|array $tagIds, string $objectType, int $limit[, string $offset = '' ]) : string[]
Parameters
$tagIds : string|array

Tag id or array of tag ids.

$objectType : string

object type

$limit : int

Count of object ids you want to get

$offset : string = ''

The last object id you already received

Tags
throws
TagNotFoundException

if at least one of the given tags does not exist

throws
InvalidArgumentException

When a limit is specified together with multiple tag ids

since
9.0.0
Return values
string[]

array of object ids or empty array if none found

getTagIdsForObjects()

Get a list of tag ids for the given object ids.

public getTagIdsForObjects(string|array $objIds, string $objectType) : array

This returns an array that maps object id to tag ids [ 1 => array('id1', 'id2'), 2 => array('id3', 'id2'), 3 => array('id5'), 4 => array() ]

Untagged objects will have an empty array associated.

Parameters
$objIds : string|array

object ids

$objectType : string

object type

Tags
since
9.0.0
Return values
array

with object id as key and an array of tag ids as value

haveTag()

Checks whether the given objects have the given tag.

public haveTag(string|array $objIds, string $objectType, string $tagId[, bool $all = true ]) : bool
Parameters
$objIds : string|array

object ids

$objectType : string

object type

$tagId : string

tag id to check

$all : bool = true

true to check that ALL objects have the tag assigned, false to check that at least ONE object has the tag.

Tags
throws
TagNotFoundException

if the tag does not exist

since
9.0.0
Return values
bool

true if the condition set by $all is matched, false otherwise

unassignTags()

Unassign the given tags from the given object.

public unassignTags(string $objId, string $objectType, string|array $tagIds) : mixed

If at least one of the given tag ids doesn't exist, none of the tags will be unassigned.

If the relationship did not exist in the first place, fail silently.

Parameters
$objId : string

object id

$objectType : string

object type

$tagIds : string|array

tag id or array of tag ids to unassign

Tags
throws
TagNotFoundException

if at least one of the given tags does not exist

since
9.0.0
Return values
mixed

Search results