WebDavCollection
extends WebDavResource
in package
Represents a collection on a WebDAV server.
Table of Contents
- PROPNAMES = [MStilkerichCardDavClientXmlElementsElementNames::SYNCTOKEN, MStilkerichCardDavClientXmlElementsElementNames::SUPPORTED_REPORT_SET, MStilkerichCardDavClientXmlElementsElementNames::ADD_MEMBER]
- List of properties to query in refreshProperties() and returned by getProperties().
- $account : Account
- The CardDAV account this resource is associated/accessible with
- $uri : string
- URI of the resource
- $client : CardDavClient
- CardDavClient object for the account's base URI
- $props : array<string, mixed>
- Cached WebDAV properties of the resource
- __construct() : mixed
- Constructs a WebDavResource object.
- createInstance() : WebDavResource
- Factory for WebDavResource objects.
- downloadResource() : array<string, string>
- Downloads the content of a given resource.
- getAccount() : Account
- Returns the Account this resource belongs to.
- getBasename() : string
- Returns the basename (last path component) of the URI of this resource.
- getChildren() : array<int, WebDavResource>
- Returns the child resources of this collection.
- getClient() : CardDavClient
- Provides a CardDavClient object to interact with the server for this resource.
- getSyncToken() : string|null
- Returns the sync token of this collection.
- getUri() : string
- Returns the URI of this resource.
- getUriPath() : string
- Returns the path component of the URI of this resource.
- jsonSerialize() : array<string, string>
- Allows to serialize WebDavResource object to JSON.
- refreshProperties() : void
- Forces a refresh of the cached standard WebDAV properties for this resource.
- supportsSyncCollection() : bool
- Queries whether the server supports the sync-collection REPORT on this collection.
- getNeededCollectionPropertyNames() : array<int, string>
- Provides the list of property names that should be requested upon call of refreshProperties().
- getProperties() : array<string, mixed>
- Returns the standard WebDAV properties for this resource.
- supportsReport() : bool
- Checks if the server supports the given REPORT on this collection.
Constants
PROPNAMES
List of properties to query in refreshProperties() and returned by getProperties().
private
mixed
PROPNAMES
= [MStilkerichCardDavClientXmlElementsElementNames::SYNCTOKEN, MStilkerichCardDavClientXmlElementsElementNames::SUPPORTED_REPORT_SET, MStilkerichCardDavClientXmlElementsElementNames::ADD_MEMBER]
Tags
Properties
$account
The CardDAV account this resource is associated/accessible with
protected
Account
$account
$uri
URI of the resource
protected
string
$uri
$client
CardDavClient object for the account's base URI
private
CardDavClient
$client
$props
Cached WebDAV properties of the resource
private
array<string, mixed>
$props
= []
Tags
Methods
__construct()
Constructs a WebDavResource object.
public
__construct(string $uri, Account $account) : mixed
Parameters
- $uri : string
-
The target URI of the resource.
- $account : Account
-
The account by which the URI shall be accessed.
Return values
mixed —createInstance()
Factory for WebDavResource objects.
public
static createInstance(string $uri, Account $account[, null|array<int, string> $restype = null ]) : WebDavResource
Given an account and URI, it attempts to create an instance of the most specific subclass matching the resource identified by the given URI. In case no resource can be accessed via the given account and URI, an exception is thrown.
Compared to direct construction of the object, creation via this factory involves querying the resourcetype of the URI with the server, so this is a checked form of instantiation whereas no server communication occurs when using the constructor.
Parameters
- $uri : string
-
The target URI of the resource.
- $account : Account
-
The account by which the URI shall be accessed.
- $restype : null|array<int, string> = null
-
Array with the DAV:resourcetype properties of the URI (if already available saves the query)
Tags
Return values
WebDavResource —An object that is an instance of the most suited subclass of WebDavResource.
downloadResource()
Downloads the content of a given resource.
public
downloadResource(string $uri) : array<string, string>
Parameters
- $uri : string
-
URI of the requested resource.
Tags
Return values
array<string, string> —An associative array where the key 'body' maps to the content of the requested resource.
getAccount()
Returns the Account this resource belongs to.
public
getAccount() : Account
Return values
Account —getBasename()
Returns the basename (last path component) of the URI of this resource.
public
getBasename() : string
Return values
string —getChildren()
Returns the child resources of this collection.
public
getChildren() : array<int, WebDavResource>
Tags
Return values
array<int, WebDavResource> —The children of this collection.
getClient()
Provides a CardDavClient object to interact with the server for this resource.
public
getClient() : CardDavClient
The base URL used by the returned client is the URL of this resource.
Return values
CardDavClient —A CardDavClient object to interact with the server for this resource.
getSyncToken()
Returns the sync token of this collection.
public
getSyncToken() : string|null
Note that the value may be cached. If this resource was just created, this is not an issue, but if a property cache may exist for a longer time call WebDavResource::refreshProperties() first to ensure an up to date sync token is provided.
Return values
string|null —The sync token, or null if the server does not provide a sync-token for this collection.
getUri()
Returns the URI of this resource.
public
getUri() : string
Return values
string —getUriPath()
Returns the path component of the URI of this resource.
public
getUriPath() : string
Return values
string —jsonSerialize()
Allows to serialize WebDavResource object to JSON.
public
jsonSerialize() : array<string, string>
Return values
array<string, string> —Associative array of attributes to serialize.
refreshProperties()
Forces a refresh of the cached standard WebDAV properties for this resource.
public
refreshProperties() : void
Tags
Return values
void —supportsSyncCollection()
Queries whether the server supports the sync-collection REPORT on this collection.
public
supportsSyncCollection() : bool
Return values
bool —True if sync-collection is supported for this collection.
getNeededCollectionPropertyNames()
Provides the list of property names that should be requested upon call of refreshProperties().
protected
getNeededCollectionPropertyNames() : array<int, string>
Return values
array<int, string> —A list of property names including namespace prefix (e. g. '{DAV:}resourcetype').
getProperties()
Returns the standard WebDAV properties for this resource.
protected
getProperties() : array<string, mixed>
Retrieved from the server on first request, cached afterwards. Use WebDavResource::refreshProperties() to force update of cached properties.
Tags
Return values
array<string, mixed> —Array mapping property name to corresponding value(s). The value type depends on the property.
supportsReport()
Checks if the server supports the given REPORT on this collection.
protected
supportsReport(string $reportElement) : bool
Parameters
- $reportElement : string
-
The XML element name of the REPORT of interest, including namespace (e.g. {DAV:}sync-collection).
Return values
bool —True if the report is supported on this collection.