CardDAV Client Library

WebDavResource
in package
implements JsonSerializable

Represents a resource on a WebDAV server.

Tags
psalm-import-type

PropTypes from Prop

Interfaces, Classes and Traits

JsonSerializable

Table of Contents

PROPNAMES  = [MStilkerichCardDavClientXmlElementsElementNames::RESTYPE]
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.
getClient()  : CardDavClient
Provides a CardDavClient object to interact with the server for this resource.
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.
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.

Constants

PROPNAMES

List of properties to query in refreshProperties() and returned by getProperties().

private mixed PROPNAMES = [MStilkerichCardDavClientXmlElementsElementNames::RESTYPE]
Tags
psalm-var

list

Properties

$account

The CardDAV account this resource is associated/accessible with

protected Account $account

$props

Cached WebDAV properties of the resource

private array<string, mixed> $props = []
Tags
psalm-var

PropTypes

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
psalm-param

null|list $restype

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
psalm-return

array{body: string}

Return values
array<string, string>

An associative array where the key 'body' maps to the content of the requested resource.

getBasename()

Returns the basename (last path component) of the URI of this resource.

public getBasename() : string
Return values
string

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.

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.

getNeededCollectionPropertyNames()

Provides the list of property names that should be requested upon call of refreshProperties().

protected getNeededCollectionPropertyNames() : array<int, string>
Tags
psalm-return

list

see
WebDavResource::getProperties()
see
WebDavResource::refreshProperties()
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
psalm-return

PropTypes

Return values
array<string, mixed>

Array mapping property name to corresponding value(s). The value type depends on the property.

Search results