Nextcloud PHP API (master)

ISystemTagObjectMapper

Public interface to access and manage system-wide tags.

Tags
since
9.0.0

Table of Contents

Methods

assignTags()  : mixed
Assign the given tags to the given object.
getAvailableObjectTypes()  : array<string|int, string>
Get the list of object types that have objects assigned to them.
getObjectIdsForTags()  : array<string|int, string>
Get a list of objects tagged with $tagIds.
getTagIdsForObjects()  : array<string|int, mixed>
Get a list of tag ids for the given object ids.
haveTag()  : bool
Checks whether the given objects have the given tag.
setObjectIdsForTag()  : void
Set the list of object ids for 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<string|int, mixed> $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<string|int, mixed>

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

getAvailableObjectTypes()

Get the list of object types that have objects assigned to them.

public getAvailableObjectTypes() : array<string|int, string>
Tags
since
31.0.0
Return values
array<string|int, string>

list of object types

getObjectIdsForTags()

Get a list of objects tagged with $tagIds.

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

Tag id or array of tag ids.

$objectType : string

object type

$limit : int = 0

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
array<string|int, 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<string|int, mixed> $objIds, string $objectType) : array<string|int, mixed>

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<string|int, mixed>

object ids

$objectType : string

object type

Tags
since
9.0.0
Return values
array<string|int, mixed>

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<string|int, mixed> $objIds, string $objectType, string $tagId[, bool $all = true ]) : bool
Parameters
$objIds : string|array<string|int, mixed>

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

setObjectIdsForTag()

Set the list of object ids for the given tag.

public setObjectIdsForTag(string $tagId, string $objectType, array<string|int, string> $objectIds) : void

This will replace the current list of object ids.

Parameters
$tagId : string

tag id

$objectType : string

object type

$objectIds : array<string|int, string>

list of object ids

Tags
throws
TagNotFoundException

if the tag does not exist

since
31.0.0

unassignTags()

Unassign the given tags from the given object.

public unassignTags(string $objId, string $objectType, string|array<string|int, mixed> $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<string|int, mixed>

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

        
On this page

Search results