Nextcloud PHP API (master)

IFilesMetadataManager

Manager for FilesMetadata; manage files' metadata.

Tags
since
28.0.0

Table of Contents

Constants

PROCESS_BACKGROUND  = 2
PROCESS_LIVE  = 1
PROCESS_NAMED  = 4

Methods

deleteMetadata()  : void
delete metadata and its indexes
getKnownMetadata()  : IFilesMetadata
returns all type of metadata currently available.
getMetadata()  : IFilesMetadata
returns metadata of a file id
getMetadataForFiles()  : array<string|int, mixed>
returns metadata of multiple file ids
getMetadataQuery()  : IMetadataQuery
generate and return a MetadataQuery to help building sql queries
initMetadata()  : void
Initiate a metadata key with its type.
refreshMetadata()  : IFilesMetadata
initiate the process of refreshing the metadata in relation to a node usually, this process: - get current metadata from database, if available, or create a new one - dispatch a MetadataLiveEvent, - save new metadata in database, if metadata have been changed during the event - refresh metadata indexes if needed, - prep a new cronjob if an app request it during the event,
saveMetadata()  : void
save metadata to database and refresh indexes.

Constants

Methods

deleteMetadata()

delete metadata and its indexes

public deleteMetadata(int $fileId) : void
Parameters
$fileId : int

file id

Tags
since
28.0.0

getKnownMetadata()

returns all type of metadata currently available.

public getKnownMetadata() : IFilesMetadata

The list is stored in a IFilesMetadata with null values but correct type.

Note: this method loads lazy appconfig values.

Tags
since
28.0.0
Return values
IFilesMetadata

getMetadataForFiles()

returns metadata of multiple file ids

public getMetadataForFiles(array<string|int, int> $fileIds) : array<string|int, mixed>
Parameters
$fileIds : array<string|int, int>

file ids

Tags
psalm-return

array<int, IFilesMetadata>

since
28.0.0
Return values
array<string|int, mixed>

File ID is the array key, files without metadata are not returned in the array

initMetadata()

Initiate a metadata key with its type.

public initMetadata(string $key, string $type, bool $indexed, int $editPermission) : void

The call is mandatory before using the metadata property in a webdav request. The call should be part of a migration/repair step and not be called on app's boot process as it is using lazy-appconfig value

Note: this method loads lazy appconfig values.

Parameters
$key : string

metadata key

$type : string

metadata type

$indexed : bool

TRUE if metadata can be search

$editPermission : int

remote edit permission via Webdav PROPPATCH

Tags
see
IMetadataValueWrapper::TYPE_INT
see
IMetadataValueWrapper::TYPE_FLOAT
see
IMetadataValueWrapper::TYPE_BOOL
see
IMetadataValueWrapper::TYPE_ARRAY
see
IMetadataValueWrapper::TYPE_STRING_LIST
see
IMetadataValueWrapper::TYPE_INT_LIST
see
IMetadataValueWrapper::TYPE_STRING
see
IMetadataValueWrapper::EDIT_FORBIDDEN
see
IMetadataValueWrapper::EDIT_REQ_OWNERSHIP
see
IMetadataValueWrapper::EDIT_REQ_WRITE_PERMISSION
see
IMetadataValueWrapper::EDIT_REQ_READ_PERMISSION
since
28.0.0
since
29.0.0

uses lazy config value - do not use this method out of repair steps

refreshMetadata()

initiate the process of refreshing the metadata in relation to a node usually, this process: - get current metadata from database, if available, or create a new one - dispatch a MetadataLiveEvent, - save new metadata in database, if metadata have been changed during the event - refresh metadata indexes if needed, - prep a new cronjob if an app request it during the event,

public refreshMetadata(Node $node[, int $process = self::PROCESS_LIVE ][, string $namedEvent = '' ]) : IFilesMetadata
Parameters
$node : Node

related node

$process : int = self::PROCESS_LIVE

type of process

$namedEvent : string = ''

limit process to a named event

Tags
see
self::PROCESS_BACKGROUND
see
self::PROCESS_LIVE
see
self::PROCESS_NAMED
since
28.0.0
Return values
IFilesMetadata

saveMetadata()

save metadata to database and refresh indexes.

public saveMetadata(IFilesMetadata $filesMetadata) : void

metadata are saved if new data are available. on update, a check on syncToken is done to avoid conflict (race condition)

Parameters
$filesMetadata : IFilesMetadata
Tags
throws
FilesMetadataException

if metadata seems malformed

since
28.0.0

        
On this page

Search results