Documentation

MkCol extends PropPatch
in package

This class represents a MKCOL operation.

MKCOL creates a new collection. MKCOL comes in two flavours:

  1. MKCOL with no body, signifies the creation of a simple collection.
  2. MKCOL with a request body. This can create a collection with a specific resource type, and a set of properties that should be set on the new collection. This can be used to create caldav calendars, carddav address books, etc.

Property updates must always be atomic. This means that a property update must either completely succeed, or completely fail.

Tags
copyright

Copyright (C) fruux GmbH (https://fruux.com/)

author

Evert Pot (http://evertpot.com/)

license

http://sabre.io/license/ Modified BSD License

Table of Contents

$failed  : bool
This property will be set to true if the operation failed.
$mutations  : array<string|int, mixed>
Properties that are being updated.
$propertyUpdateCallbacks  : array<string|int, mixed>
This is the list of callbacks when we're performing the actual update.
$resourceType  : array<string|int, mixed>
A list of resource-types in clark-notation.
$result  : array<string|int, mixed>
A list of properties and the result of the update. The result is in the form of a HTTP status code.
__construct()  : mixed
Creates the MKCOL object.
commit()  : bool
Performs the actual update, and calls all callbacks.
getMutations()  : array<string|int, mixed>
Returns the full list of mutations.
getRemainingMutations()  : array<string|int, string>
Returns the list of properties that don't have a result code yet.
getRemainingValues()  : array<string|int, mixed>
Returns the list of properties that don't have a result code yet.
getResourceType()  : array<string|int, string>
Returns the resourcetype of the new collection.
getResult()  : array<string|int, mixed>
Returns the result of the operation.
handle()  : mixed
Call this function if you wish to handle updating certain properties.
handleRemaining()  : mixed
Call this function if you wish to handle _all_ properties that haven't been handled by anything else yet. Note that you effectively claim with this that you promise to process _all_ properties that are coming in.
hasResourceType()  : bool
Returns true or false if the MKCOL operation has at least the specified resource type.
setRemainingResultCode()  : mixed
Sets the result code for all properties that did not have a result yet.
setResultCode()  : mixed
Sets the result code for one or more properties.
doCallBackMultiProp()  : mixed
Executes a property callback with the multi-property syntax.
doCallBackSingleProp()  : mixed
Executes a property callback with the single-property syntax.

Properties

$failed

This property will be set to true if the operation failed.

protected bool $failed = false

$mutations

Properties that are being updated.

protected array<string|int, mixed> $mutations

This is a key-value list. If the value is null, the property is supposed to be deleted.

$propertyUpdateCallbacks

This is the list of callbacks when we're performing the actual update.

protected array<string|int, mixed> $propertyUpdateCallbacks = []

$resourceType

A list of resource-types in clark-notation.

protected array<string|int, mixed> $resourceType

$result

A list of properties and the result of the update. The result is in the form of a HTTP status code.

protected array<string|int, mixed> $result = []

Methods

__construct()

Creates the MKCOL object.

public __construct(array<string|int, string> $resourceType, array<string|int, mixed> $mutations) : mixed
Parameters
$resourceType : array<string|int, string>

list of resourcetype values

$mutations : array<string|int, mixed>

list of new properties values

Return values
mixed

commit()

Performs the actual update, and calls all callbacks.

public commit() : bool

This method returns true or false depending on if the operation was successful.

Return values
bool

getMutations()

Returns the full list of mutations.

public getMutations() : array<string|int, mixed>
Return values
array<string|int, mixed>

getRemainingMutations()

Returns the list of properties that don't have a result code yet.

public getRemainingMutations() : array<string|int, string>

This method returns a list of property names, but not its values.

Return values
array<string|int, string>

getRemainingValues()

Returns the list of properties that don't have a result code yet.

public getRemainingValues() : array<string|int, mixed>

This method returns list of properties and their values.

Return values
array<string|int, mixed>

getResourceType()

Returns the resourcetype of the new collection.

public getResourceType() : array<string|int, string>
Return values
array<string|int, string>

getResult()

Returns the result of the operation.

public getResult() : array<string|int, mixed>
Return values
array<string|int, mixed>

handle()

Call this function if you wish to handle updating certain properties.

public handle(string|array<string|int, string> $properties, callable $callback) : mixed

For instance, your class may be responsible for handling updates for the {DAV:}displayname property.

In that case, call this method with the first argument "{DAV:}displayname" and a second argument that's a method that does the actual updating.

It's possible to specify more than one property as an array.

The callback must return a boolean or an it. If the result is true, the operation was considered successful. If it's false, it's consided failed.

If the result is an integer, we'll use that integer as the http status code associated with the operation.

Parameters
$properties : string|array<string|int, string>
$callback : callable
Return values
mixed

handleRemaining()

Call this function if you wish to handle _all_ properties that haven't been handled by anything else yet. Note that you effectively claim with this that you promise to process _all_ properties that are coming in.

public handleRemaining(callable $callback) : mixed
Parameters
$callback : callable
Return values
mixed

hasResourceType()

Returns true or false if the MKCOL operation has at least the specified resource type.

public hasResourceType(string|array<string|int, string> $resourceType) : bool

If the resourcetype is specified as an array, all resourcetypes are checked.

Parameters
$resourceType : string|array<string|int, string>
Return values
bool

setRemainingResultCode()

Sets the result code for all properties that did not have a result yet.

public setRemainingResultCode(int $resultCode) : mixed
Parameters
$resultCode : int
Return values
mixed

setResultCode()

Sets the result code for one or more properties.

public setResultCode(string|array<string|int, string> $properties, int $resultCode) : mixed
Parameters
$properties : string|array<string|int, string>
$resultCode : int
Return values
mixed

doCallBackMultiProp()

Executes a property callback with the multi-property syntax.

private doCallBackMultiProp(array<string|int, mixed> $propertyList, callable $callback) : mixed
Parameters
$propertyList : array<string|int, mixed>
$callback : callable
Return values
mixed

doCallBackSingleProp()

Executes a property callback with the single-property syntax.

private doCallBackSingleProp(string $propertyName, callable $callback) : mixed
Parameters
$propertyName : string
$callback : callable
Return values
mixed

Search results