PropFind.php 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <?php
  2. declare(strict_types=1);
  3. namespace Sabre\DAV\Xml\Request;
  4. use Sabre\Xml\Element\KeyValue;
  5. use Sabre\Xml\Reader;
  6. use Sabre\Xml\XmlDeserializable;
  7. /**
  8. * WebDAV PROPFIND request parser.
  9. *
  10. * This class parses the {DAV:}propfind request, as defined in:
  11. *
  12. * https://tools.ietf.org/html/rfc4918#section-14.20
  13. *
  14. * @copyright Copyright (C) fruux GmbH (https://fruux.com/)
  15. * @author Evert Pot (http://www.rooftopsolutions.nl/)
  16. * @license http://sabre.io/license/ Modified BSD License
  17. */
  18. class PropFind implements XmlDeserializable
  19. {
  20. /**
  21. * If this is set to true, this was an 'allprop' request.
  22. *
  23. * @var bool
  24. */
  25. public $allProp = false;
  26. /**
  27. * The property list.
  28. *
  29. * @var array|null
  30. */
  31. public $properties;
  32. /**
  33. * The deserialize method is called during xml parsing.
  34. *
  35. * This method is called statically, this is because in theory this method
  36. * may be used as a type of constructor, or factory method.
  37. *
  38. * Often you want to return an instance of the current class, but you are
  39. * free to return other data as well.
  40. *
  41. * You are responsible for advancing the reader to the next element. Not
  42. * doing anything will result in a never-ending loop.
  43. *
  44. * If you just want to skip parsing for this element altogether, you can
  45. * just call $reader->next();
  46. *
  47. * $reader->parseInnerTree() will parse the entire sub-tree, and advance to
  48. * the next element.
  49. *
  50. * @return mixed
  51. */
  52. public static function xmlDeserialize(Reader $reader)
  53. {
  54. $self = new self();
  55. $reader->pushContext();
  56. $reader->elementMap['{DAV:}prop'] = 'Sabre\Xml\Element\Elements';
  57. foreach (KeyValue::xmlDeserialize($reader) as $k => $v) {
  58. switch ($k) {
  59. case '{DAV:}prop':
  60. $self->properties = $v;
  61. break;
  62. case '{DAV:}allprop':
  63. $self->allProp = true;
  64. }
  65. }
  66. $reader->popContext();
  67. return $self;
  68. }
  69. }