ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sabre\DAV\PropFind Class Reference

This class holds all the information about a PROPFIND request. More...

+ Inheritance diagram for Sabre\DAV\PropFind:
+ Collaboration diagram for Sabre\DAV\PropFind:

Public Member Functions

 __construct ($path, array $properties, $depth=0, $requestType=self::NORMAL)
 Creates the PROPFIND object. More...
 
 handle ($propertyName, $valueOrCallBack)
 Handles a specific property. More...
 
 set ($propertyName, $value, $status=null)
 Sets the value of the property. More...
 
 get ($propertyName)
 Returns the current value for a property. More...
 
 getStatus ($propertyName)
 Returns the current status code for a property name. More...
 
 setPath ($path)
 Updates the path for this PROPFIND. More...
 
 getPath ()
 Returns the path this PROPFIND request is for. More...
 
 getDepth ()
 Returns the depth of this propfind request. More...
 
 setDepth ($depth)
 Updates the depth of this propfind request. More...
 
 get404Properties ()
 Returns all propertynames that have a 404 status, and thus don't have a value yet. More...
 
 getRequestedProperties ()
 Returns the full list of requested properties. More...
 
 isAllProps ()
 Returns true if this was an '{DAV:}allprops' request. More...
 
 getResultForMultiStatus ()
 Returns a result array that's often used in multistatus responses. More...
 

Data Fields

const NORMAL = 0
 A normal propfind. More...
 
const ALLPROPS = 1
 An allprops request. More...
 
const PROPNAME = 2
 A propname request. More...
 

Protected Attributes

 $path
 
 $depth = 0
 
 $requestType
 The type of request. More...
 
 $properties = []
 
 $result = []
 
 $itemsLeft
 

Detailed Description

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.

Definition at line 11 of file PropFind.php.

Constructor & Destructor Documentation

◆ __construct()

Sabre\DAV\PropFind::__construct (   $path,
array  $properties,
  $depth = 0,
  $requestType = self::NORMAL 
)

Creates the PROPFIND object.

Parameters
string$path
array$properties
int$depth
int$requestType

Definition at line 43 of file PropFind.php.

References Sabre\DAV\PropFind\$depth, Sabre\DAV\PropFind\$path, Sabre\DAV\PropFind\$properties, and Sabre\DAV\PropFind\$requestType.

43  {
44 
45  $this->path = $path;
46  $this->properties = $properties;
47  $this->depth = $depth;
48  $this->requestType = $requestType;
49 
50  if ($requestType === self::ALLPROPS) {
51  $this->properties = [
52  '{DAV:}getlastmodified',
53  '{DAV:}getcontentlength',
54  '{DAV:}resourcetype',
55  '{DAV:}quota-used-bytes',
56  '{DAV:}quota-available-bytes',
57  '{DAV:}getetag',
58  '{DAV:}getcontenttype',
59  ];
60  }
61 
62  foreach ($this->properties as $propertyName) {
63 
64  // Seeding properties with 404's.
65  $this->result[$propertyName] = [404, null];
66 
67  }
68  $this->itemsLeft = count($this->result);
69 
70  }
$requestType
The type of request.
Definition: PropFind.php:312

Member Function Documentation

◆ get()

Sabre\DAV\PropFind::get (   $propertyName)

Returns the current value for a property.

Parameters
string$propertyName
Returns
mixed

Definition at line 149 of file PropFind.php.

Referenced by Sabre\DAV\CorePlugin\propFindLate().

149  {
150 
151  return isset($this->result[$propertyName]) ? $this->result[$propertyName][1] : null;
152 
153  }
+ Here is the caller graph for this function:

◆ get404Properties()

Sabre\DAV\PropFind::get404Properties ( )

Returns all propertynames that have a 404 status, and thus don't have a value yet.

Returns
array

Definition at line 222 of file PropFind.php.

References Sabre\DAV\PropFind\$result.

Referenced by Sabre\DAV\PropertyStorage\Backend\PDO\propFind(), and Sabre\DAV\CorePlugin\propFindNode().

222  {
223 
224  if ($this->itemsLeft === 0) {
225  return [];
226  }
227  $result = [];
228  foreach ($this->result as $propertyName => $stuff) {
229  if ($stuff[0] === 404) {
230  $result[] = $propertyName;
231  }
232  }
233  return $result;
234 
235  }
+ Here is the caller graph for this function:

◆ getDepth()

Sabre\DAV\PropFind::getDepth ( )

Returns the depth of this propfind request.

Returns
int

Definition at line 198 of file PropFind.php.

References Sabre\DAV\PropFind\$depth.

Referenced by Sabre\DAV\Server\generatePathNodes().

198  {
199 
200  return $this->depth;
201 
202  }
+ Here is the caller graph for this function:

◆ getPath()

Sabre\DAV\PropFind::getPath ( )

Returns the path this PROPFIND request is for.

Returns
string

Definition at line 187 of file PropFind.php.

References Sabre\DAV\PropFind\$path.

Referenced by Sabre\DAV\Server\generatePathNodes(), Sabre\DAV\Browser\GuessContentType\propFind(), Sabre\DAV\PropertyStorage\Plugin\propFind(), Sabre\CalDAV\Schedule\Plugin\propFind(), Sabre\DAV\CorePlugin\propFind(), and Sabre\DAV\CorePlugin\propFindLate().

187  {
188 
189  return $this->path;
190 
191  }
+ Here is the caller graph for this function:

◆ getRequestedProperties()

Sabre\DAV\PropFind::getRequestedProperties ( )

Returns the full list of requested properties.

This returns just their names, not a status or value.

Returns
array

Definition at line 244 of file PropFind.php.

References Sabre\DAV\PropFind\$properties.

244  {
245 
246  return $this->properties;
247 
248  }

◆ getResultForMultiStatus()

Sabre\DAV\PropFind::getResultForMultiStatus ( )

Returns a result array that's often used in multistatus responses.

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' ], ]

Returns
array

Definition at line 273 of file PropFind.php.

References $info, and $r.

273  {
274 
275  $r = [
276  200 => [],
277  404 => [],
278  ];
279  foreach ($this->result as $propertyName => $info) {
280  if (!isset($r[$info[0]])) {
281  $r[$info[0]] = [$propertyName => $info[1]];
282  } else {
283  $r[$info[0]][$propertyName] = $info[1];
284  }
285  }
286  // Removing the 404's for multi-status requests.
287  if ($this->requestType === self::ALLPROPS) unset($r[404]);
288  return $r;
289 
290  }
$r
Definition: example_031.php:79
$info
Definition: index.php:5

◆ getStatus()

Sabre\DAV\PropFind::getStatus (   $propertyName)

Returns the current status code for a property name.

If the property does not appear in the list of requested properties, null will be returned.

Parameters
string$propertyName
Returns
int|null

Definition at line 164 of file PropFind.php.

Referenced by Sabre\CalDAV\Subscriptions\Plugin\propFind().

164  {
165 
166  return isset($this->result[$propertyName]) ? $this->result[$propertyName][0] : null;
167 
168  }
+ Here is the caller graph for this function:

◆ handle()

Sabre\DAV\PropFind::handle (   $propertyName,
  $valueOrCallBack 
)

Handles a specific property.

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
string$propertyName
mixed$valueOrCallBack
Returns
void

Definition at line 94 of file PropFind.php.

Referenced by Sabre\DAV\Browser\GuessContentType\propFind(), Sabre\CalDAV\Notifications\Plugin\propFind(), Sabre\DAV\Sharing\Plugin\propFind(), Sabre\CalDAV\Schedule\Plugin\propFind(), Sabre\DAV\CorePlugin\propFind(), and Sabre\DAV\CorePlugin\propFindLate().

94  {
95 
96  if ($this->itemsLeft && isset($this->result[$propertyName]) && $this->result[$propertyName][0] === 404) {
97  if (is_callable($valueOrCallBack)) {
98  $value = $valueOrCallBack();
99  } else {
100  $value = $valueOrCallBack;
101  }
102  if (!is_null($value)) {
103  $this->itemsLeft--;
104  $this->result[$propertyName] = [200, $value];
105  }
106  }
107 
108  }
+ Here is the caller graph for this function:

◆ isAllProps()

Sabre\DAV\PropFind::isAllProps ( )

Returns true if this was an '{DAV:}allprops' request.

Returns
bool

Definition at line 255 of file PropFind.php.

Referenced by Sabre\DAV\PropertyStorage\Backend\PDO\propFind().

255  {
256 
257  return $this->requestType === self::ALLPROPS;
258 
259  }
+ Here is the caller graph for this function:

◆ set()

Sabre\DAV\PropFind::set (   $propertyName,
  $value,
  $status = null 
)

Sets the value of the property.

If status is not supplied, the status will default to 200 for non-null properties, and 404 for null properties.

Parameters
string$propertyName
mixed$value
int$status
Returns
void

Definition at line 121 of file PropFind.php.

Referenced by Sabre\DAV\PropertyStorage\Backend\Mock\propFind(), Sabre\CalDAV\Subscriptions\Plugin\propFind(), Sabre\DAV\PropertyStorage\Backend\PDO\propFind(), Sabre\CalDAV\Schedule\Plugin\propFind(), and Sabre\DAV\CorePlugin\propFindNode().

121  {
122 
123  if (is_null($status)) {
124  $status = is_null($value) ? 404 : 200;
125  }
126  // If this is an ALLPROPS request and the property is
127  // unknown, add it to the result; else ignore it:
128  if (!isset($this->result[$propertyName])) {
129  if ($this->requestType === self::ALLPROPS) {
130  $this->result[$propertyName] = [$status, $value];
131  }
132  return;
133  }
134  if ($status !== 404 && $this->result[$propertyName][0] === 404) {
135  $this->itemsLeft--;
136  } elseif ($status === 404 && $this->result[$propertyName][0] !== 404) {
137  $this->itemsLeft++;
138  }
139  $this->result[$propertyName] = [$status, $value];
140 
141  }
+ Here is the caller graph for this function:

◆ setDepth()

Sabre\DAV\PropFind::setDepth (   $depth)

Updates the depth of this propfind request.

Parameters
int$depth
Returns
void

Definition at line 210 of file PropFind.php.

References Sabre\DAV\PropFind\$depth.

Referenced by Sabre\DAV\Server\generatePathNodes().

210  {
211 
212  $this->depth = $depth;
213 
214  }
+ Here is the caller graph for this function:

◆ setPath()

Sabre\DAV\PropFind::setPath (   $path)

Updates the path for this PROPFIND.

Parameters
string$path
Returns
void

Definition at line 176 of file PropFind.php.

References Sabre\DAV\PropFind\$path.

176  {
177 
178  $this->path = $path;
179 
180  }

Field Documentation

◆ $depth

Sabre\DAV\PropFind::$depth = 0
protected

◆ $itemsLeft

Sabre\DAV\PropFind::$itemsLeft
protected

Definition at line 345 of file PropFind.php.

◆ $path

◆ $properties

Sabre\DAV\PropFind::$properties = []
protected

◆ $requestType

Sabre\DAV\PropFind::$requestType
protected

The type of request.

See the TYPE constants

Definition at line 312 of file PropFind.php.

Referenced by Sabre\DAV\PropFind\__construct().

◆ $result

Sabre\DAV\PropFind::$result = []
protected

◆ ALLPROPS

const Sabre\DAV\PropFind::ALLPROPS = 1

An allprops request.

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.

Definition at line 27 of file PropFind.php.

Referenced by Sabre\DAV\Server\getPropertiesIteratorForPath(), Sabre\DAV\PropFindTest\testAllPropDefaults(), and Sabre\DAV\PropFindTest\testSetAllpropCustom().

◆ NORMAL

const Sabre\DAV\PropFind::NORMAL = 0

A normal propfind.

Definition at line 16 of file PropFind.php.

Referenced by Sabre\DAV\Server\getPropertiesIteratorForPath().

◆ PROPNAME

const Sabre\DAV\PropFind::PROPNAME = 2

A propname request.

This just returns a list of properties that are defined on a node, without their values.

Definition at line 33 of file PropFind.php.


The documentation for this class was generated from the following file: