PropFind
in package
This class holds all the information about a PROPFIND request.
It contains the type of PROPFIND request, which properties were requested and also the returned items.
Table of Contents
- ALLPROPS = 1
- An allprops request.
- NORMAL = 0
- A normal propfind.
- PROPNAME = 2
- A propname request. This just returns a list of properties that are defined on a node, without their values.
- $depth : int
- The Depth of the request.
- $itemsLeft : int
- This is used as an internal counter for the number of properties that do not yet have a value.
- $path : string
- The path that we're fetching properties for.
- $properties : array<string|int, mixed>
- A list of requested properties.
- $requestType : mixed
- The type of request. See the TYPE constants.
- $result : array<string|int, mixed>
- The result of the operation.
- __construct() : mixed
- Creates the PROPFIND object.
- get() : mixed
- Returns the current value for a property.
- get404Properties() : array<string|int, mixed>
- Returns all propertynames that have a 404 status, and thus don't have a value yet.
- getDepth() : int
- Returns the depth of this propfind request.
- getPath() : string
- Returns the path this PROPFIND request is for.
- getRequestedProperties() : array<string|int, mixed>
- Returns the full list of requested properties.
- getResultForMultiStatus() : array<string|int, mixed>
- Returns a result array that's often used in multistatus responses.
- getStatus() : int|null
- Returns the current status code for a property name.
- handle() : mixed
- Handles a specific property.
- isAllProps() : bool
- Returns true if this was an '{DAV:}allprops' request.
- set() : mixed
- Sets the value of the property.
- setDepth() : mixed
- Updates the depth of this propfind request.
- setPath() : mixed
- Updates the path for this PROPFIND.
Constants
ALLPROPS
An allprops request.
public
mixed
ALLPROPS
= 1
While this was originally intended for instructing the server to really fetch every property, because it was used so often and it's so heavy this turned into a small list of default properties after a while.
So 'all properties' now means a hardcoded list.
NORMAL
A normal propfind.
public
mixed
NORMAL
= 0
PROPNAME
A propname request. This just returns a list of properties that are defined on a node, without their values.
public
mixed
PROPNAME
= 2
Properties
$depth
The Depth of the request.
protected
int
$depth
= 0
0 means only the current item. 1 means the current item + its children. It can also be DEPTH_INFINITY if this is enabled in the server.
$itemsLeft
This is used as an internal counter for the number of properties that do not yet have a value.
protected
int
$itemsLeft
$path
The path that we're fetching properties for.
protected
string
$path
$properties
A list of requested properties.
protected
array<string|int, mixed>
$properties
= []
$requestType
The type of request. See the TYPE constants.
protected
mixed
$requestType
$result
The result of the operation.
protected
array<string|int, mixed>
$result
= []
The keys in this array are property names. The values are an array with two elements: the http status code and then optionally a value.
Example:
[ "{DAV:}owner" : [404], "{DAV:}displayname" : [200, "Admin"] ]
Methods
__construct()
Creates the PROPFIND object.
public
__construct(string $path, array<string|int, mixed> $properties, int $depth[, int $requestType = self::NORMAL ]) : mixed
Parameters
- $path : string
- $properties : array<string|int, mixed>
- $depth : int
- $requestType : int = self::NORMAL
Return values
mixed —get()
Returns the current value for a property.
public
get(string $propertyName) : mixed
Parameters
- $propertyName : string
Return values
mixed —get404Properties()
Returns all propertynames that have a 404 status, and thus don't have a value yet.
public
get404Properties() : array<string|int, mixed>
Return values
array<string|int, mixed> —getDepth()
Returns the depth of this propfind request.
public
getDepth() : int
Return values
int —getPath()
Returns the path this PROPFIND request is for.
public
getPath() : string
Return values
string —getRequestedProperties()
Returns the full list of requested properties.
public
getRequestedProperties() : array<string|int, mixed>
This returns just their names, not a status or value.
Return values
array<string|int, mixed> —getResultForMultiStatus()
Returns a result array that's often used in multistatus responses.
public
getResultForMultiStatus() : array<string|int, mixed>
The array uses status codes as keys, and property names and value pairs as the value of the top array.. such as :
[ 200 => [ '{DAV:}displayname' => 'foo' ], ]
Return values
array<string|int, mixed> —getStatus()
Returns the current status code for a property name.
public
getStatus(string $propertyName) : int|null
If the property does not appear in the list of requested properties, null will be returned.
Parameters
- $propertyName : string
Return values
int|null —handle()
Handles a specific property.
public
handle(string $propertyName, mixed $valueOrCallBack) : mixed
This method checks whether the specified property was requested in this PROPFIND request, and if so, it will call the callback and use the return value for it's value.
Example:
$propFind->handle('{DAV:}displayname', function() { return 'hello'; });
Note that handle will only work the first time. If null is returned, the value is ignored.
It's also possible to not pass a callback, but immediately pass a value
Parameters
- $propertyName : string
- $valueOrCallBack : mixed
Return values
mixed —isAllProps()
Returns true if this was an '{DAV:}allprops' request.
public
isAllProps() : bool
Return values
bool —set()
Sets the value of the property.
public
set(string $propertyName, mixed $value[, int $status = null ]) : mixed
If status is not supplied, the status will default to 200 for non-null properties, and 404 for null properties.
Parameters
- $propertyName : string
- $value : mixed
- $status : int = null
Return values
mixed —setDepth()
Updates the depth of this propfind request.
public
setDepth(int $depth) : mixed
Parameters
- $depth : int
Return values
mixed —setPath()
Updates the path for this PROPFIND.
public
setPath(string $path) : mixed
Parameters
- $path : string