WebDavCollection
extends WebDavResource
in package
Represents a collection on a WebDAV server.
Table of Contents
Constants
- PROPNAMES : mixed = [\MStilkerich\CardDavClient\XmlElements\Element...
- List of properties to query in refreshProperties() and returned by getProperties().
Properties
- $account : Account
- The CardDAV account this resource is associated/accessible with
- $uri : string
- URI of the resource
Methods
- __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
= [\MStilkerich\CardDavClient\XmlElements\ElementNames::SYNCTOKEN, \MStilkerich\CardDavClient\XmlElements\ElementNames::SUPPORTED_REPORT_SET, \MStilkerich\CardDavClient\XmlElements\ElementNames::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
Methods
__construct()
Constructs a WebDavResource object.
public
__construct(string $uri, Account $account) : mixed
Parameters
- $uri : string
-
The target URI of the resource. The account's credentials are sent to the origin of this URI, see WebDavResource.
- $account : Account
-
The account by which the URI shall be accessed.
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. The account's credentials are sent to the origin of this URI, see WebDavResource.
- $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>
The account's credentials are only sent with the request if the given URI has the same origin as this resource, or the auth_origin_callback of the account permits it. Therefore, this method can be used to download resources from URIs of untrusted sources, such as photo URIs contained in VCards.
Parameters
- $uri : string
-
URI of the requested resource. If relative, it is taken relative to the URI of this 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
AccountgetBasename()
Returns the basename (last path component) of the URI of this resource.
public
getBasename() : string
Return values
stringgetChildren()
Returns the child resources of this collection.
public
getChildren() : array<int, WebDavResource>
Only direct members of the collection are returned, i.e. resources with the same origin as the collection and the collection's path plus one path segment. Other resources reported by the server are ignored, so that the account's credentials are not sent to locations outside the collection.
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
stringgetUriPath()
Returns the path component of the URI of this resource.
public
getUriPath() : string
Return values
stringjsonSerialize()
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
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.