@@ -21,89 +21,89 @@ |
||
21 | 21 | */ |
22 | 22 | class PropPatch implements Element |
23 | 23 | { |
24 | - /** |
|
25 | - * The list of properties that will be updated and removed. |
|
26 | - * |
|
27 | - * If a property will be removed, it's value will be set to null. |
|
28 | - * |
|
29 | - * @var array |
|
30 | - */ |
|
31 | - public $properties = []; |
|
24 | + /** |
|
25 | + * The list of properties that will be updated and removed. |
|
26 | + * |
|
27 | + * If a property will be removed, it's value will be set to null. |
|
28 | + * |
|
29 | + * @var array |
|
30 | + */ |
|
31 | + public $properties = []; |
|
32 | 32 | |
33 | - /** |
|
34 | - * The xmlSerialize method is called during xml writing. |
|
35 | - * |
|
36 | - * Use the $writer argument to write its own xml serialization. |
|
37 | - * |
|
38 | - * An important note: do _not_ create a parent element. Any element |
|
39 | - * implementing XmlSerializable should only ever write what's considered |
|
40 | - * its 'inner xml'. |
|
41 | - * |
|
42 | - * The parent of the current element is responsible for writing a |
|
43 | - * containing element. |
|
44 | - * |
|
45 | - * This allows serializers to be re-used for different element names. |
|
46 | - * |
|
47 | - * If you are opening new elements, you must also close them again. |
|
48 | - */ |
|
49 | - public function xmlSerialize(Writer $writer) |
|
50 | - { |
|
51 | - foreach ($this->properties as $propertyName => $propertyValue) { |
|
52 | - if (is_null($propertyValue)) { |
|
53 | - $writer->startElement('{DAV:}remove'); |
|
54 | - $writer->write(['{DAV:}prop' => [$propertyName => $propertyValue]]); |
|
55 | - $writer->endElement(); |
|
56 | - } else { |
|
57 | - $writer->startElement('{DAV:}set'); |
|
58 | - $writer->write(['{DAV:}prop' => [$propertyName => $propertyValue]]); |
|
59 | - $writer->endElement(); |
|
60 | - } |
|
61 | - } |
|
62 | - } |
|
33 | + /** |
|
34 | + * The xmlSerialize method is called during xml writing. |
|
35 | + * |
|
36 | + * Use the $writer argument to write its own xml serialization. |
|
37 | + * |
|
38 | + * An important note: do _not_ create a parent element. Any element |
|
39 | + * implementing XmlSerializable should only ever write what's considered |
|
40 | + * its 'inner xml'. |
|
41 | + * |
|
42 | + * The parent of the current element is responsible for writing a |
|
43 | + * containing element. |
|
44 | + * |
|
45 | + * This allows serializers to be re-used for different element names. |
|
46 | + * |
|
47 | + * If you are opening new elements, you must also close them again. |
|
48 | + */ |
|
49 | + public function xmlSerialize(Writer $writer) |
|
50 | + { |
|
51 | + foreach ($this->properties as $propertyName => $propertyValue) { |
|
52 | + if (is_null($propertyValue)) { |
|
53 | + $writer->startElement('{DAV:}remove'); |
|
54 | + $writer->write(['{DAV:}prop' => [$propertyName => $propertyValue]]); |
|
55 | + $writer->endElement(); |
|
56 | + } else { |
|
57 | + $writer->startElement('{DAV:}set'); |
|
58 | + $writer->write(['{DAV:}prop' => [$propertyName => $propertyValue]]); |
|
59 | + $writer->endElement(); |
|
60 | + } |
|
61 | + } |
|
62 | + } |
|
63 | 63 | |
64 | - /** |
|
65 | - * The deserialize method is called during xml parsing. |
|
66 | - * |
|
67 | - * This method is called statically, this is because in theory this method |
|
68 | - * may be used as a type of constructor, or factory method. |
|
69 | - * |
|
70 | - * Often you want to return an instance of the current class, but you are |
|
71 | - * free to return other data as well. |
|
72 | - * |
|
73 | - * You are responsible for advancing the reader to the next element. Not |
|
74 | - * doing anything will result in a never-ending loop. |
|
75 | - * |
|
76 | - * If you just want to skip parsing for this element altogether, you can |
|
77 | - * just call $reader->next(); |
|
78 | - * |
|
79 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
80 | - * the next element. |
|
81 | - * |
|
82 | - * @return mixed |
|
83 | - */ |
|
84 | - public static function xmlDeserialize(Reader $reader) |
|
85 | - { |
|
86 | - $self = new self(); |
|
64 | + /** |
|
65 | + * The deserialize method is called during xml parsing. |
|
66 | + * |
|
67 | + * This method is called statically, this is because in theory this method |
|
68 | + * may be used as a type of constructor, or factory method. |
|
69 | + * |
|
70 | + * Often you want to return an instance of the current class, but you are |
|
71 | + * free to return other data as well. |
|
72 | + * |
|
73 | + * You are responsible for advancing the reader to the next element. Not |
|
74 | + * doing anything will result in a never-ending loop. |
|
75 | + * |
|
76 | + * If you just want to skip parsing for this element altogether, you can |
|
77 | + * just call $reader->next(); |
|
78 | + * |
|
79 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
80 | + * the next element. |
|
81 | + * |
|
82 | + * @return mixed |
|
83 | + */ |
|
84 | + public static function xmlDeserialize(Reader $reader) |
|
85 | + { |
|
86 | + $self = new self(); |
|
87 | 87 | |
88 | - $elementMap = $reader->elementMap; |
|
89 | - $elementMap['{DAV:}prop'] = 'Sabre\DAV\Xml\Element\Prop'; |
|
90 | - $elementMap['{DAV:}set'] = 'Sabre\Xml\Element\KeyValue'; |
|
91 | - $elementMap['{DAV:}remove'] = 'Sabre\Xml\Element\KeyValue'; |
|
88 | + $elementMap = $reader->elementMap; |
|
89 | + $elementMap['{DAV:}prop'] = 'Sabre\DAV\Xml\Element\Prop'; |
|
90 | + $elementMap['{DAV:}set'] = 'Sabre\Xml\Element\KeyValue'; |
|
91 | + $elementMap['{DAV:}remove'] = 'Sabre\Xml\Element\KeyValue'; |
|
92 | 92 | |
93 | - $elems = $reader->parseInnerTree($elementMap); |
|
93 | + $elems = $reader->parseInnerTree($elementMap); |
|
94 | 94 | |
95 | - foreach ($elems as $elem) { |
|
96 | - if ('{DAV:}set' === $elem['name']) { |
|
97 | - $self->properties = array_merge($self->properties, $elem['value']['{DAV:}prop']); |
|
98 | - } |
|
99 | - if ('{DAV:}remove' === $elem['name']) { |
|
100 | - // Ensuring there are no values. |
|
101 | - foreach ($elem['value']['{DAV:}prop'] as $remove => $value) { |
|
102 | - $self->properties[$remove] = null; |
|
103 | - } |
|
104 | - } |
|
105 | - } |
|
95 | + foreach ($elems as $elem) { |
|
96 | + if ('{DAV:}set' === $elem['name']) { |
|
97 | + $self->properties = array_merge($self->properties, $elem['value']['{DAV:}prop']); |
|
98 | + } |
|
99 | + if ('{DAV:}remove' === $elem['name']) { |
|
100 | + // Ensuring there are no values. |
|
101 | + foreach ($elem['value']['{DAV:}prop'] as $remove => $value) { |
|
102 | + $self->properties[$remove] = null; |
|
103 | + } |
|
104 | + } |
|
105 | + } |
|
106 | 106 | |
107 | - return $self; |
|
108 | - } |
|
107 | + return $self; |
|
108 | + } |
|
109 | 109 | } |
@@ -20,61 +20,61 @@ |
||
20 | 20 | */ |
21 | 21 | class MkCol implements XmlDeserializable |
22 | 22 | { |
23 | - /** |
|
24 | - * The list of properties that will be set. |
|
25 | - * |
|
26 | - * @var array |
|
27 | - */ |
|
28 | - protected $properties = []; |
|
23 | + /** |
|
24 | + * The list of properties that will be set. |
|
25 | + * |
|
26 | + * @var array |
|
27 | + */ |
|
28 | + protected $properties = []; |
|
29 | 29 | |
30 | - /** |
|
31 | - * Returns a key=>value array with properties that are supposed to get set |
|
32 | - * during creation of the new collection. |
|
33 | - * |
|
34 | - * @return array |
|
35 | - */ |
|
36 | - public function getProperties() |
|
37 | - { |
|
38 | - return $this->properties; |
|
39 | - } |
|
30 | + /** |
|
31 | + * Returns a key=>value array with properties that are supposed to get set |
|
32 | + * during creation of the new collection. |
|
33 | + * |
|
34 | + * @return array |
|
35 | + */ |
|
36 | + public function getProperties() |
|
37 | + { |
|
38 | + return $this->properties; |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * The deserialize method is called during xml parsing. |
|
43 | - * |
|
44 | - * This method is called statically, this is because in theory this method |
|
45 | - * may be used as a type of constructor, or factory method. |
|
46 | - * |
|
47 | - * Often you want to return an instance of the current class, but you are |
|
48 | - * free to return other data as well. |
|
49 | - * |
|
50 | - * You are responsible for advancing the reader to the next element. Not |
|
51 | - * doing anything will result in a never-ending loop. |
|
52 | - * |
|
53 | - * If you just want to skip parsing for this element altogether, you can |
|
54 | - * just call $reader->next(); |
|
55 | - * |
|
56 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
57 | - * the next element. |
|
58 | - * |
|
59 | - * @return mixed |
|
60 | - */ |
|
61 | - public static function xmlDeserialize(Reader $reader) |
|
62 | - { |
|
63 | - $self = new self(); |
|
41 | + /** |
|
42 | + * The deserialize method is called during xml parsing. |
|
43 | + * |
|
44 | + * This method is called statically, this is because in theory this method |
|
45 | + * may be used as a type of constructor, or factory method. |
|
46 | + * |
|
47 | + * Often you want to return an instance of the current class, but you are |
|
48 | + * free to return other data as well. |
|
49 | + * |
|
50 | + * You are responsible for advancing the reader to the next element. Not |
|
51 | + * doing anything will result in a never-ending loop. |
|
52 | + * |
|
53 | + * If you just want to skip parsing for this element altogether, you can |
|
54 | + * just call $reader->next(); |
|
55 | + * |
|
56 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
57 | + * the next element. |
|
58 | + * |
|
59 | + * @return mixed |
|
60 | + */ |
|
61 | + public static function xmlDeserialize(Reader $reader) |
|
62 | + { |
|
63 | + $self = new self(); |
|
64 | 64 | |
65 | - $elementMap = $reader->elementMap; |
|
66 | - $elementMap['{DAV:}prop'] = 'Sabre\DAV\Xml\Element\Prop'; |
|
67 | - $elementMap['{DAV:}set'] = 'Sabre\Xml\Element\KeyValue'; |
|
68 | - $elementMap['{DAV:}remove'] = 'Sabre\Xml\Element\KeyValue'; |
|
65 | + $elementMap = $reader->elementMap; |
|
66 | + $elementMap['{DAV:}prop'] = 'Sabre\DAV\Xml\Element\Prop'; |
|
67 | + $elementMap['{DAV:}set'] = 'Sabre\Xml\Element\KeyValue'; |
|
68 | + $elementMap['{DAV:}remove'] = 'Sabre\Xml\Element\KeyValue'; |
|
69 | 69 | |
70 | - $elems = $reader->parseInnerTree($elementMap); |
|
70 | + $elems = $reader->parseInnerTree($elementMap); |
|
71 | 71 | |
72 | - foreach ($elems as $elem) { |
|
73 | - if ('{DAV:}set' === $elem['name']) { |
|
74 | - $self->properties = array_merge($self->properties, $elem['value']['{DAV:}prop']); |
|
75 | - } |
|
76 | - } |
|
72 | + foreach ($elems as $elem) { |
|
73 | + if ('{DAV:}set' === $elem['name']) { |
|
74 | + $self->properties = array_merge($self->properties, $elem['value']['{DAV:}prop']); |
|
75 | + } |
|
76 | + } |
|
77 | 77 | |
78 | - return $self; |
|
79 | - } |
|
78 | + return $self; |
|
79 | + } |
|
80 | 80 | } |
@@ -21,60 +21,60 @@ |
||
21 | 21 | */ |
22 | 22 | class ShareResource implements XmlDeserializable |
23 | 23 | { |
24 | - /** |
|
25 | - * The list of new people added or updated or removed from the share. |
|
26 | - * |
|
27 | - * @var Sharee[] |
|
28 | - */ |
|
29 | - public $sharees = []; |
|
24 | + /** |
|
25 | + * The list of new people added or updated or removed from the share. |
|
26 | + * |
|
27 | + * @var Sharee[] |
|
28 | + */ |
|
29 | + public $sharees = []; |
|
30 | 30 | |
31 | - /** |
|
32 | - * Constructor. |
|
33 | - * |
|
34 | - * @param Sharee[] $sharees |
|
35 | - */ |
|
36 | - public function __construct(array $sharees) |
|
37 | - { |
|
38 | - $this->sharees = $sharees; |
|
39 | - } |
|
31 | + /** |
|
32 | + * Constructor. |
|
33 | + * |
|
34 | + * @param Sharee[] $sharees |
|
35 | + */ |
|
36 | + public function __construct(array $sharees) |
|
37 | + { |
|
38 | + $this->sharees = $sharees; |
|
39 | + } |
|
40 | 40 | |
41 | - /** |
|
42 | - * The deserialize method is called during xml parsing. |
|
43 | - * |
|
44 | - * This method is called statically, this is because in theory this method |
|
45 | - * may be used as a type of constructor, or factory method. |
|
46 | - * |
|
47 | - * Often you want to return an instance of the current class, but you are |
|
48 | - * free to return other data as well. |
|
49 | - * |
|
50 | - * You are responsible for advancing the reader to the next element. Not |
|
51 | - * doing anything will result in a never-ending loop. |
|
52 | - * |
|
53 | - * If you just want to skip parsing for this element altogether, you can |
|
54 | - * just call $reader->next(); |
|
55 | - * |
|
56 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
57 | - * the next element. |
|
58 | - * |
|
59 | - * @return mixed |
|
60 | - */ |
|
61 | - public static function xmlDeserialize(Reader $reader) |
|
62 | - { |
|
63 | - $elems = $reader->parseInnerTree([ |
|
64 | - '{DAV:}sharee' => 'Sabre\DAV\Xml\Element\Sharee', |
|
65 | - '{DAV:}share-access' => 'Sabre\DAV\Xml\Property\ShareAccess', |
|
66 | - '{DAV:}prop' => 'Sabre\Xml\Deserializer\keyValue', |
|
67 | - ]); |
|
41 | + /** |
|
42 | + * The deserialize method is called during xml parsing. |
|
43 | + * |
|
44 | + * This method is called statically, this is because in theory this method |
|
45 | + * may be used as a type of constructor, or factory method. |
|
46 | + * |
|
47 | + * Often you want to return an instance of the current class, but you are |
|
48 | + * free to return other data as well. |
|
49 | + * |
|
50 | + * You are responsible for advancing the reader to the next element. Not |
|
51 | + * doing anything will result in a never-ending loop. |
|
52 | + * |
|
53 | + * If you just want to skip parsing for this element altogether, you can |
|
54 | + * just call $reader->next(); |
|
55 | + * |
|
56 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
57 | + * the next element. |
|
58 | + * |
|
59 | + * @return mixed |
|
60 | + */ |
|
61 | + public static function xmlDeserialize(Reader $reader) |
|
62 | + { |
|
63 | + $elems = $reader->parseInnerTree([ |
|
64 | + '{DAV:}sharee' => 'Sabre\DAV\Xml\Element\Sharee', |
|
65 | + '{DAV:}share-access' => 'Sabre\DAV\Xml\Property\ShareAccess', |
|
66 | + '{DAV:}prop' => 'Sabre\Xml\Deserializer\keyValue', |
|
67 | + ]); |
|
68 | 68 | |
69 | - $sharees = []; |
|
69 | + $sharees = []; |
|
70 | 70 | |
71 | - foreach ($elems as $elem) { |
|
72 | - if ('{DAV:}sharee' !== $elem['name']) { |
|
73 | - continue; |
|
74 | - } |
|
75 | - $sharees[] = $elem['value']; |
|
76 | - } |
|
71 | + foreach ($elems as $elem) { |
|
72 | + if ('{DAV:}sharee' !== $elem['name']) { |
|
73 | + continue; |
|
74 | + } |
|
75 | + $sharees[] = $elem['value']; |
|
76 | + } |
|
77 | 77 | |
78 | - return new self($sharees); |
|
79 | - } |
|
78 | + return new self($sharees); |
|
79 | + } |
|
80 | 80 | } |
@@ -22,97 +22,97 @@ |
||
22 | 22 | */ |
23 | 23 | class SyncCollectionReport implements XmlDeserializable |
24 | 24 | { |
25 | - /** |
|
26 | - * The sync-token the client supplied for the report. |
|
27 | - * |
|
28 | - * @var string|null |
|
29 | - */ |
|
30 | - public $syncToken; |
|
31 | - |
|
32 | - /** |
|
33 | - * The 'depth' of the sync the client is interested in. |
|
34 | - * |
|
35 | - * @var int |
|
36 | - */ |
|
37 | - public $syncLevel; |
|
38 | - |
|
39 | - /** |
|
40 | - * Maximum amount of items returned. |
|
41 | - * |
|
42 | - * @var int|null |
|
43 | - */ |
|
44 | - public $limit; |
|
45 | - |
|
46 | - /** |
|
47 | - * The list of properties that are being requested for every change. |
|
48 | - * |
|
49 | - * @var array|null |
|
50 | - */ |
|
51 | - public $properties; |
|
52 | - |
|
53 | - /** |
|
54 | - * The deserialize method is called during xml parsing. |
|
55 | - * |
|
56 | - * This method is called statically, this is because in theory this method |
|
57 | - * may be used as a type of constructor, or factory method. |
|
58 | - * |
|
59 | - * Often you want to return an instance of the current class, but you are |
|
60 | - * free to return other data as well. |
|
61 | - * |
|
62 | - * You are responsible for advancing the reader to the next element. Not |
|
63 | - * doing anything will result in a never-ending loop. |
|
64 | - * |
|
65 | - * If you just want to skip parsing for this element altogether, you can |
|
66 | - * just call $reader->next(); |
|
67 | - * |
|
68 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
69 | - * the next element. |
|
70 | - * |
|
71 | - * @return mixed |
|
72 | - */ |
|
73 | - public static function xmlDeserialize(Reader $reader) |
|
74 | - { |
|
75 | - $self = new self(); |
|
76 | - |
|
77 | - $reader->pushContext(); |
|
78 | - |
|
79 | - $reader->elementMap['{DAV:}prop'] = 'Sabre\Xml\Element\Elements'; |
|
80 | - $elems = KeyValue::xmlDeserialize($reader); |
|
81 | - |
|
82 | - $reader->popContext(); |
|
83 | - |
|
84 | - $required = [ |
|
85 | - '{DAV:}sync-token', |
|
86 | - '{DAV:}prop', |
|
87 | - ]; |
|
88 | - |
|
89 | - foreach ($required as $elem) { |
|
90 | - if (!array_key_exists($elem, $elems)) { |
|
91 | - throw new BadRequest('The '.$elem.' element in the {DAV:}sync-collection report is required'); |
|
92 | - } |
|
93 | - } |
|
94 | - |
|
95 | - $self->properties = $elems['{DAV:}prop']; |
|
96 | - $self->syncToken = $elems['{DAV:}sync-token']; |
|
97 | - |
|
98 | - if (isset($elems['{DAV:}limit'])) { |
|
99 | - $nresults = null; |
|
100 | - foreach ($elems['{DAV:}limit'] as $child) { |
|
101 | - if ('{DAV:}nresults' === $child['name']) { |
|
102 | - $nresults = (int) $child['value']; |
|
103 | - } |
|
104 | - } |
|
105 | - $self->limit = $nresults; |
|
106 | - } |
|
107 | - |
|
108 | - if (isset($elems['{DAV:}sync-level'])) { |
|
109 | - $value = $elems['{DAV:}sync-level']; |
|
110 | - if ('infinity' === $value) { |
|
111 | - $value = \Sabre\DAV\Server::DEPTH_INFINITY; |
|
112 | - } |
|
113 | - $self->syncLevel = $value; |
|
114 | - } |
|
115 | - |
|
116 | - return $self; |
|
117 | - } |
|
25 | + /** |
|
26 | + * The sync-token the client supplied for the report. |
|
27 | + * |
|
28 | + * @var string|null |
|
29 | + */ |
|
30 | + public $syncToken; |
|
31 | + |
|
32 | + /** |
|
33 | + * The 'depth' of the sync the client is interested in. |
|
34 | + * |
|
35 | + * @var int |
|
36 | + */ |
|
37 | + public $syncLevel; |
|
38 | + |
|
39 | + /** |
|
40 | + * Maximum amount of items returned. |
|
41 | + * |
|
42 | + * @var int|null |
|
43 | + */ |
|
44 | + public $limit; |
|
45 | + |
|
46 | + /** |
|
47 | + * The list of properties that are being requested for every change. |
|
48 | + * |
|
49 | + * @var array|null |
|
50 | + */ |
|
51 | + public $properties; |
|
52 | + |
|
53 | + /** |
|
54 | + * The deserialize method is called during xml parsing. |
|
55 | + * |
|
56 | + * This method is called statically, this is because in theory this method |
|
57 | + * may be used as a type of constructor, or factory method. |
|
58 | + * |
|
59 | + * Often you want to return an instance of the current class, but you are |
|
60 | + * free to return other data as well. |
|
61 | + * |
|
62 | + * You are responsible for advancing the reader to the next element. Not |
|
63 | + * doing anything will result in a never-ending loop. |
|
64 | + * |
|
65 | + * If you just want to skip parsing for this element altogether, you can |
|
66 | + * just call $reader->next(); |
|
67 | + * |
|
68 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
69 | + * the next element. |
|
70 | + * |
|
71 | + * @return mixed |
|
72 | + */ |
|
73 | + public static function xmlDeserialize(Reader $reader) |
|
74 | + { |
|
75 | + $self = new self(); |
|
76 | + |
|
77 | + $reader->pushContext(); |
|
78 | + |
|
79 | + $reader->elementMap['{DAV:}prop'] = 'Sabre\Xml\Element\Elements'; |
|
80 | + $elems = KeyValue::xmlDeserialize($reader); |
|
81 | + |
|
82 | + $reader->popContext(); |
|
83 | + |
|
84 | + $required = [ |
|
85 | + '{DAV:}sync-token', |
|
86 | + '{DAV:}prop', |
|
87 | + ]; |
|
88 | + |
|
89 | + foreach ($required as $elem) { |
|
90 | + if (!array_key_exists($elem, $elems)) { |
|
91 | + throw new BadRequest('The '.$elem.' element in the {DAV:}sync-collection report is required'); |
|
92 | + } |
|
93 | + } |
|
94 | + |
|
95 | + $self->properties = $elems['{DAV:}prop']; |
|
96 | + $self->syncToken = $elems['{DAV:}sync-token']; |
|
97 | + |
|
98 | + if (isset($elems['{DAV:}limit'])) { |
|
99 | + $nresults = null; |
|
100 | + foreach ($elems['{DAV:}limit'] as $child) { |
|
101 | + if ('{DAV:}nresults' === $child['name']) { |
|
102 | + $nresults = (int) $child['value']; |
|
103 | + } |
|
104 | + } |
|
105 | + $self->limit = $nresults; |
|
106 | + } |
|
107 | + |
|
108 | + if (isset($elems['{DAV:}sync-level'])) { |
|
109 | + $value = $elems['{DAV:}sync-level']; |
|
110 | + if ('infinity' === $value) { |
|
111 | + $value = \Sabre\DAV\Server::DEPTH_INFINITY; |
|
112 | + } |
|
113 | + $self->syncLevel = $value; |
|
114 | + } |
|
115 | + |
|
116 | + return $self; |
|
117 | + } |
|
118 | 118 | } |
@@ -21,59 +21,59 @@ |
||
21 | 21 | */ |
22 | 22 | class PropFind implements XmlDeserializable |
23 | 23 | { |
24 | - /** |
|
25 | - * If this is set to true, this was an 'allprop' request. |
|
26 | - * |
|
27 | - * @var bool |
|
28 | - */ |
|
29 | - public $allProp = false; |
|
24 | + /** |
|
25 | + * If this is set to true, this was an 'allprop' request. |
|
26 | + * |
|
27 | + * @var bool |
|
28 | + */ |
|
29 | + public $allProp = false; |
|
30 | 30 | |
31 | - /** |
|
32 | - * The property list. |
|
33 | - * |
|
34 | - * @var array|null |
|
35 | - */ |
|
36 | - public $properties; |
|
31 | + /** |
|
32 | + * The property list. |
|
33 | + * |
|
34 | + * @var array|null |
|
35 | + */ |
|
36 | + public $properties; |
|
37 | 37 | |
38 | - /** |
|
39 | - * The deserialize method is called during xml parsing. |
|
40 | - * |
|
41 | - * This method is called statically, this is because in theory this method |
|
42 | - * may be used as a type of constructor, or factory method. |
|
43 | - * |
|
44 | - * Often you want to return an instance of the current class, but you are |
|
45 | - * free to return other data as well. |
|
46 | - * |
|
47 | - * You are responsible for advancing the reader to the next element. Not |
|
48 | - * doing anything will result in a never-ending loop. |
|
49 | - * |
|
50 | - * If you just want to skip parsing for this element altogether, you can |
|
51 | - * just call $reader->next(); |
|
52 | - * |
|
53 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
54 | - * the next element. |
|
55 | - * |
|
56 | - * @return mixed |
|
57 | - */ |
|
58 | - public static function xmlDeserialize(Reader $reader) |
|
59 | - { |
|
60 | - $self = new self(); |
|
38 | + /** |
|
39 | + * The deserialize method is called during xml parsing. |
|
40 | + * |
|
41 | + * This method is called statically, this is because in theory this method |
|
42 | + * may be used as a type of constructor, or factory method. |
|
43 | + * |
|
44 | + * Often you want to return an instance of the current class, but you are |
|
45 | + * free to return other data as well. |
|
46 | + * |
|
47 | + * You are responsible for advancing the reader to the next element. Not |
|
48 | + * doing anything will result in a never-ending loop. |
|
49 | + * |
|
50 | + * If you just want to skip parsing for this element altogether, you can |
|
51 | + * just call $reader->next(); |
|
52 | + * |
|
53 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
54 | + * the next element. |
|
55 | + * |
|
56 | + * @return mixed |
|
57 | + */ |
|
58 | + public static function xmlDeserialize(Reader $reader) |
|
59 | + { |
|
60 | + $self = new self(); |
|
61 | 61 | |
62 | - $reader->pushContext(); |
|
63 | - $reader->elementMap['{DAV:}prop'] = 'Sabre\Xml\Element\Elements'; |
|
62 | + $reader->pushContext(); |
|
63 | + $reader->elementMap['{DAV:}prop'] = 'Sabre\Xml\Element\Elements'; |
|
64 | 64 | |
65 | - foreach (KeyValue::xmlDeserialize($reader) as $k => $v) { |
|
66 | - switch ($k) { |
|
67 | - case '{DAV:}prop': |
|
68 | - $self->properties = $v; |
|
69 | - break; |
|
70 | - case '{DAV:}allprop': |
|
71 | - $self->allProp = true; |
|
72 | - } |
|
73 | - } |
|
65 | + foreach (KeyValue::xmlDeserialize($reader) as $k => $v) { |
|
66 | + switch ($k) { |
|
67 | + case '{DAV:}prop': |
|
68 | + $self->properties = $v; |
|
69 | + break; |
|
70 | + case '{DAV:}allprop': |
|
71 | + $self->allProp = true; |
|
72 | + } |
|
73 | + } |
|
74 | 74 | |
75 | - $reader->popContext(); |
|
75 | + $reader->popContext(); |
|
76 | 76 | |
77 | - return $self; |
|
78 | - } |
|
77 | + return $self; |
|
78 | + } |
|
79 | 79 | } |
@@ -23,114 +23,114 @@ |
||
23 | 23 | */ |
24 | 24 | class MultiStatus implements Element |
25 | 25 | { |
26 | - /** |
|
27 | - * The responses. |
|
28 | - * |
|
29 | - * @var \Sabre\DAV\Xml\Element\Response[] |
|
30 | - */ |
|
31 | - protected $responses; |
|
26 | + /** |
|
27 | + * The responses. |
|
28 | + * |
|
29 | + * @var \Sabre\DAV\Xml\Element\Response[] |
|
30 | + */ |
|
31 | + protected $responses; |
|
32 | 32 | |
33 | - /** |
|
34 | - * A sync token (from RFC6578). |
|
35 | - * |
|
36 | - * @var string |
|
37 | - */ |
|
38 | - protected $syncToken; |
|
33 | + /** |
|
34 | + * A sync token (from RFC6578). |
|
35 | + * |
|
36 | + * @var string |
|
37 | + */ |
|
38 | + protected $syncToken; |
|
39 | 39 | |
40 | - /** |
|
41 | - * Constructor. |
|
42 | - * |
|
43 | - * @param \Sabre\DAV\Xml\Element\Response[] $responses |
|
44 | - * @param string $syncToken |
|
45 | - */ |
|
46 | - public function __construct(array $responses, $syncToken = null) |
|
47 | - { |
|
48 | - $this->responses = $responses; |
|
49 | - $this->syncToken = $syncToken; |
|
50 | - } |
|
40 | + /** |
|
41 | + * Constructor. |
|
42 | + * |
|
43 | + * @param \Sabre\DAV\Xml\Element\Response[] $responses |
|
44 | + * @param string $syncToken |
|
45 | + */ |
|
46 | + public function __construct(array $responses, $syncToken = null) |
|
47 | + { |
|
48 | + $this->responses = $responses; |
|
49 | + $this->syncToken = $syncToken; |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Returns the response list. |
|
54 | - * |
|
55 | - * @return \Sabre\DAV\Xml\Element\Response[] |
|
56 | - */ |
|
57 | - public function getResponses() |
|
58 | - { |
|
59 | - return $this->responses; |
|
60 | - } |
|
52 | + /** |
|
53 | + * Returns the response list. |
|
54 | + * |
|
55 | + * @return \Sabre\DAV\Xml\Element\Response[] |
|
56 | + */ |
|
57 | + public function getResponses() |
|
58 | + { |
|
59 | + return $this->responses; |
|
60 | + } |
|
61 | 61 | |
62 | - /** |
|
63 | - * Returns the sync-token, if available. |
|
64 | - * |
|
65 | - * @return string|null |
|
66 | - */ |
|
67 | - public function getSyncToken() |
|
68 | - { |
|
69 | - return $this->syncToken; |
|
70 | - } |
|
62 | + /** |
|
63 | + * Returns the sync-token, if available. |
|
64 | + * |
|
65 | + * @return string|null |
|
66 | + */ |
|
67 | + public function getSyncToken() |
|
68 | + { |
|
69 | + return $this->syncToken; |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * The serialize method is called during xml writing. |
|
74 | - * |
|
75 | - * It should use the $writer argument to encode this object into XML. |
|
76 | - * |
|
77 | - * Important note: it is not needed to create the parent element. The |
|
78 | - * parent element is already created, and we only have to worry about |
|
79 | - * attributes, child elements and text (if any). |
|
80 | - * |
|
81 | - * Important note 2: If you are writing any new elements, you are also |
|
82 | - * responsible for closing them. |
|
83 | - */ |
|
84 | - public function xmlSerialize(Writer $writer) |
|
85 | - { |
|
86 | - foreach ($this->getResponses() as $response) { |
|
87 | - $writer->writeElement('{DAV:}response', $response); |
|
88 | - } |
|
89 | - if ($syncToken = $this->getSyncToken()) { |
|
90 | - $writer->writeElement('{DAV:}sync-token', $syncToken); |
|
91 | - } |
|
92 | - } |
|
72 | + /** |
|
73 | + * The serialize method is called during xml writing. |
|
74 | + * |
|
75 | + * It should use the $writer argument to encode this object into XML. |
|
76 | + * |
|
77 | + * Important note: it is not needed to create the parent element. The |
|
78 | + * parent element is already created, and we only have to worry about |
|
79 | + * attributes, child elements and text (if any). |
|
80 | + * |
|
81 | + * Important note 2: If you are writing any new elements, you are also |
|
82 | + * responsible for closing them. |
|
83 | + */ |
|
84 | + public function xmlSerialize(Writer $writer) |
|
85 | + { |
|
86 | + foreach ($this->getResponses() as $response) { |
|
87 | + $writer->writeElement('{DAV:}response', $response); |
|
88 | + } |
|
89 | + if ($syncToken = $this->getSyncToken()) { |
|
90 | + $writer->writeElement('{DAV:}sync-token', $syncToken); |
|
91 | + } |
|
92 | + } |
|
93 | 93 | |
94 | - /** |
|
95 | - * The deserialize method is called during xml parsing. |
|
96 | - * |
|
97 | - * This method is called statically, this is because in theory this method |
|
98 | - * may be used as a type of constructor, or factory method. |
|
99 | - * |
|
100 | - * Often you want to return an instance of the current class, but you are |
|
101 | - * free to return other data as well. |
|
102 | - * |
|
103 | - * You are responsible for advancing the reader to the next element. Not |
|
104 | - * doing anything will result in a never-ending loop. |
|
105 | - * |
|
106 | - * If you just want to skip parsing for this element altogether, you can |
|
107 | - * just call $reader->next(); |
|
108 | - * |
|
109 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
110 | - * the next element. |
|
111 | - * |
|
112 | - * @return mixed |
|
113 | - */ |
|
114 | - public static function xmlDeserialize(Reader $reader) |
|
115 | - { |
|
116 | - $elementMap = $reader->elementMap; |
|
117 | - $elementMap['{DAV:}prop'] = 'Sabre\\DAV\\Xml\\Element\\Prop'; |
|
118 | - $elements = $reader->parseInnerTree($elementMap); |
|
94 | + /** |
|
95 | + * The deserialize method is called during xml parsing. |
|
96 | + * |
|
97 | + * This method is called statically, this is because in theory this method |
|
98 | + * may be used as a type of constructor, or factory method. |
|
99 | + * |
|
100 | + * Often you want to return an instance of the current class, but you are |
|
101 | + * free to return other data as well. |
|
102 | + * |
|
103 | + * You are responsible for advancing the reader to the next element. Not |
|
104 | + * doing anything will result in a never-ending loop. |
|
105 | + * |
|
106 | + * If you just want to skip parsing for this element altogether, you can |
|
107 | + * just call $reader->next(); |
|
108 | + * |
|
109 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
110 | + * the next element. |
|
111 | + * |
|
112 | + * @return mixed |
|
113 | + */ |
|
114 | + public static function xmlDeserialize(Reader $reader) |
|
115 | + { |
|
116 | + $elementMap = $reader->elementMap; |
|
117 | + $elementMap['{DAV:}prop'] = 'Sabre\\DAV\\Xml\\Element\\Prop'; |
|
118 | + $elements = $reader->parseInnerTree($elementMap); |
|
119 | 119 | |
120 | - $responses = []; |
|
121 | - $syncToken = null; |
|
120 | + $responses = []; |
|
121 | + $syncToken = null; |
|
122 | 122 | |
123 | - if ($elements) { |
|
124 | - foreach ($elements as $elem) { |
|
125 | - if ('{DAV:}response' === $elem['name']) { |
|
126 | - $responses[] = $elem['value']; |
|
127 | - } |
|
128 | - if ('{DAV:}sync-token' === $elem['name']) { |
|
129 | - $syncToken = $elem['value']; |
|
130 | - } |
|
131 | - } |
|
132 | - } |
|
123 | + if ($elements) { |
|
124 | + foreach ($elements as $elem) { |
|
125 | + if ('{DAV:}response' === $elem['name']) { |
|
126 | + $responses[] = $elem['value']; |
|
127 | + } |
|
128 | + if ('{DAV:}sync-token' === $elem['name']) { |
|
129 | + $syncToken = $elem['value']; |
|
130 | + } |
|
131 | + } |
|
132 | + } |
|
133 | 133 | |
134 | - return new self($responses, $syncToken); |
|
135 | - } |
|
134 | + return new self($responses, $syncToken); |
|
135 | + } |
|
136 | 136 | } |
@@ -24,43 +24,43 @@ |
||
24 | 24 | */ |
25 | 25 | class Invite implements XmlSerializable |
26 | 26 | { |
27 | - /** |
|
28 | - * A list of sharees. |
|
29 | - * |
|
30 | - * @var Sharee[] |
|
31 | - */ |
|
32 | - public $sharees = []; |
|
27 | + /** |
|
28 | + * A list of sharees. |
|
29 | + * |
|
30 | + * @var Sharee[] |
|
31 | + */ |
|
32 | + public $sharees = []; |
|
33 | 33 | |
34 | - /** |
|
35 | - * Creates the property. |
|
36 | - * |
|
37 | - * @param Sharee[] $sharees |
|
38 | - */ |
|
39 | - public function __construct(array $sharees) |
|
40 | - { |
|
41 | - $this->sharees = $sharees; |
|
42 | - } |
|
34 | + /** |
|
35 | + * Creates the property. |
|
36 | + * |
|
37 | + * @param Sharee[] $sharees |
|
38 | + */ |
|
39 | + public function __construct(array $sharees) |
|
40 | + { |
|
41 | + $this->sharees = $sharees; |
|
42 | + } |
|
43 | 43 | |
44 | - /** |
|
45 | - * The xmlSerialize method is called during xml writing. |
|
46 | - * |
|
47 | - * Use the $writer argument to write its own xml serialization. |
|
48 | - * |
|
49 | - * An important note: do _not_ create a parent element. Any element |
|
50 | - * implementing XmlSerializable should only ever write what's considered |
|
51 | - * its 'inner xml'. |
|
52 | - * |
|
53 | - * The parent of the current element is responsible for writing a |
|
54 | - * containing element. |
|
55 | - * |
|
56 | - * This allows serializers to be re-used for different element names. |
|
57 | - * |
|
58 | - * If you are opening new elements, you must also close them again. |
|
59 | - */ |
|
60 | - public function xmlSerialize(Writer $writer) |
|
61 | - { |
|
62 | - foreach ($this->sharees as $sharee) { |
|
63 | - $writer->writeElement('{DAV:}sharee', $sharee); |
|
64 | - } |
|
65 | - } |
|
44 | + /** |
|
45 | + * The xmlSerialize method is called during xml writing. |
|
46 | + * |
|
47 | + * Use the $writer argument to write its own xml serialization. |
|
48 | + * |
|
49 | + * An important note: do _not_ create a parent element. Any element |
|
50 | + * implementing XmlSerializable should only ever write what's considered |
|
51 | + * its 'inner xml'. |
|
52 | + * |
|
53 | + * The parent of the current element is responsible for writing a |
|
54 | + * containing element. |
|
55 | + * |
|
56 | + * This allows serializers to be re-used for different element names. |
|
57 | + * |
|
58 | + * If you are opening new elements, you must also close them again. |
|
59 | + */ |
|
60 | + public function xmlSerialize(Writer $writer) |
|
61 | + { |
|
62 | + foreach ($this->sharees as $sharee) { |
|
63 | + $writer->writeElement('{DAV:}sharee', $sharee); |
|
64 | + } |
|
65 | + } |
|
66 | 66 | } |
@@ -25,120 +25,120 @@ |
||
25 | 25 | */ |
26 | 26 | class SupportedReportSet implements XmlSerializable, HtmlOutput |
27 | 27 | { |
28 | - /** |
|
29 | - * List of reports. |
|
30 | - * |
|
31 | - * @var array |
|
32 | - */ |
|
33 | - protected $reports = []; |
|
28 | + /** |
|
29 | + * List of reports. |
|
30 | + * |
|
31 | + * @var array |
|
32 | + */ |
|
33 | + protected $reports = []; |
|
34 | 34 | |
35 | - /** |
|
36 | - * Creates the property. |
|
37 | - * |
|
38 | - * Any reports passed in the constructor |
|
39 | - * should be valid report-types in clark-notation. |
|
40 | - * |
|
41 | - * Either a string or an array of strings must be passed. |
|
42 | - * |
|
43 | - * @param string|string[] $reports |
|
44 | - */ |
|
45 | - public function __construct($reports = null) |
|
46 | - { |
|
47 | - if (!is_null($reports)) { |
|
48 | - $this->addReport($reports); |
|
49 | - } |
|
50 | - } |
|
35 | + /** |
|
36 | + * Creates the property. |
|
37 | + * |
|
38 | + * Any reports passed in the constructor |
|
39 | + * should be valid report-types in clark-notation. |
|
40 | + * |
|
41 | + * Either a string or an array of strings must be passed. |
|
42 | + * |
|
43 | + * @param string|string[] $reports |
|
44 | + */ |
|
45 | + public function __construct($reports = null) |
|
46 | + { |
|
47 | + if (!is_null($reports)) { |
|
48 | + $this->addReport($reports); |
|
49 | + } |
|
50 | + } |
|
51 | 51 | |
52 | - /** |
|
53 | - * Adds a report to this property. |
|
54 | - * |
|
55 | - * The report must be a string in clark-notation. |
|
56 | - * Multiple reports can be specified as an array. |
|
57 | - * |
|
58 | - * @param mixed $report |
|
59 | - */ |
|
60 | - public function addReport($report) |
|
61 | - { |
|
62 | - $report = (array) $report; |
|
52 | + /** |
|
53 | + * Adds a report to this property. |
|
54 | + * |
|
55 | + * The report must be a string in clark-notation. |
|
56 | + * Multiple reports can be specified as an array. |
|
57 | + * |
|
58 | + * @param mixed $report |
|
59 | + */ |
|
60 | + public function addReport($report) |
|
61 | + { |
|
62 | + $report = (array) $report; |
|
63 | 63 | |
64 | - foreach ($report as $r) { |
|
65 | - if (!preg_match('/^{([^}]*)}(.*)$/', $r)) { |
|
66 | - throw new DAV\Exception('Reportname must be in clark-notation'); |
|
67 | - } |
|
68 | - $this->reports[] = $r; |
|
69 | - } |
|
70 | - } |
|
64 | + foreach ($report as $r) { |
|
65 | + if (!preg_match('/^{([^}]*)}(.*)$/', $r)) { |
|
66 | + throw new DAV\Exception('Reportname must be in clark-notation'); |
|
67 | + } |
|
68 | + $this->reports[] = $r; |
|
69 | + } |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * Returns the list of supported reports. |
|
74 | - * |
|
75 | - * @return string[] |
|
76 | - */ |
|
77 | - public function getValue() |
|
78 | - { |
|
79 | - return $this->reports; |
|
80 | - } |
|
72 | + /** |
|
73 | + * Returns the list of supported reports. |
|
74 | + * |
|
75 | + * @return string[] |
|
76 | + */ |
|
77 | + public function getValue() |
|
78 | + { |
|
79 | + return $this->reports; |
|
80 | + } |
|
81 | 81 | |
82 | - /** |
|
83 | - * Returns true or false if the property contains a specific report. |
|
84 | - * |
|
85 | - * @param string $reportName |
|
86 | - * |
|
87 | - * @return bool |
|
88 | - */ |
|
89 | - public function has($reportName) |
|
90 | - { |
|
91 | - return in_array( |
|
92 | - $reportName, |
|
93 | - $this->reports |
|
94 | - ); |
|
95 | - } |
|
82 | + /** |
|
83 | + * Returns true or false if the property contains a specific report. |
|
84 | + * |
|
85 | + * @param string $reportName |
|
86 | + * |
|
87 | + * @return bool |
|
88 | + */ |
|
89 | + public function has($reportName) |
|
90 | + { |
|
91 | + return in_array( |
|
92 | + $reportName, |
|
93 | + $this->reports |
|
94 | + ); |
|
95 | + } |
|
96 | 96 | |
97 | - /** |
|
98 | - * The xmlSerialize method is called during xml writing. |
|
99 | - * |
|
100 | - * Use the $writer argument to write its own xml serialization. |
|
101 | - * |
|
102 | - * An important note: do _not_ create a parent element. Any element |
|
103 | - * implementing XmlSerializable should only ever write what's considered |
|
104 | - * its 'inner xml'. |
|
105 | - * |
|
106 | - * The parent of the current element is responsible for writing a |
|
107 | - * containing element. |
|
108 | - * |
|
109 | - * This allows serializers to be re-used for different element names. |
|
110 | - * |
|
111 | - * If you are opening new elements, you must also close them again. |
|
112 | - */ |
|
113 | - public function xmlSerialize(Writer $writer) |
|
114 | - { |
|
115 | - foreach ($this->getValue() as $val) { |
|
116 | - $writer->startElement('{DAV:}supported-report'); |
|
117 | - $writer->startElement('{DAV:}report'); |
|
118 | - $writer->writeElement($val); |
|
119 | - $writer->endElement(); |
|
120 | - $writer->endElement(); |
|
121 | - } |
|
122 | - } |
|
97 | + /** |
|
98 | + * The xmlSerialize method is called during xml writing. |
|
99 | + * |
|
100 | + * Use the $writer argument to write its own xml serialization. |
|
101 | + * |
|
102 | + * An important note: do _not_ create a parent element. Any element |
|
103 | + * implementing XmlSerializable should only ever write what's considered |
|
104 | + * its 'inner xml'. |
|
105 | + * |
|
106 | + * The parent of the current element is responsible for writing a |
|
107 | + * containing element. |
|
108 | + * |
|
109 | + * This allows serializers to be re-used for different element names. |
|
110 | + * |
|
111 | + * If you are opening new elements, you must also close them again. |
|
112 | + */ |
|
113 | + public function xmlSerialize(Writer $writer) |
|
114 | + { |
|
115 | + foreach ($this->getValue() as $val) { |
|
116 | + $writer->startElement('{DAV:}supported-report'); |
|
117 | + $writer->startElement('{DAV:}report'); |
|
118 | + $writer->writeElement($val); |
|
119 | + $writer->endElement(); |
|
120 | + $writer->endElement(); |
|
121 | + } |
|
122 | + } |
|
123 | 123 | |
124 | - /** |
|
125 | - * Generate html representation for this value. |
|
126 | - * |
|
127 | - * The html output is 100% trusted, and no effort is being made to sanitize |
|
128 | - * it. It's up to the implementor to sanitize user provided values. |
|
129 | - * |
|
130 | - * The output must be in UTF-8. |
|
131 | - * |
|
132 | - * The baseUri parameter is a url to the root of the application, and can |
|
133 | - * be used to construct local links. |
|
134 | - * |
|
135 | - * @return string |
|
136 | - */ |
|
137 | - public function toHtml(HtmlOutputHelper $html) |
|
138 | - { |
|
139 | - return implode( |
|
140 | - ', ', |
|
141 | - array_map([$html, 'xmlName'], $this->getValue()) |
|
142 | - ); |
|
143 | - } |
|
124 | + /** |
|
125 | + * Generate html representation for this value. |
|
126 | + * |
|
127 | + * The html output is 100% trusted, and no effort is being made to sanitize |
|
128 | + * it. It's up to the implementor to sanitize user provided values. |
|
129 | + * |
|
130 | + * The output must be in UTF-8. |
|
131 | + * |
|
132 | + * The baseUri parameter is a url to the root of the application, and can |
|
133 | + * be used to construct local links. |
|
134 | + * |
|
135 | + * @return string |
|
136 | + */ |
|
137 | + public function toHtml(HtmlOutputHelper $html) |
|
138 | + { |
|
139 | + return implode( |
|
140 | + ', ', |
|
141 | + array_map([$html, 'xmlName'], $this->getValue()) |
|
142 | + ); |
|
143 | + } |
|
144 | 144 | } |
@@ -26,110 +26,110 @@ |
||
26 | 26 | */ |
27 | 27 | class ShareAccess implements Element |
28 | 28 | { |
29 | - /** |
|
30 | - * Either SHARED or SHAREDOWNER. |
|
31 | - * |
|
32 | - * @var int |
|
33 | - */ |
|
34 | - protected $value; |
|
29 | + /** |
|
30 | + * Either SHARED or SHAREDOWNER. |
|
31 | + * |
|
32 | + * @var int |
|
33 | + */ |
|
34 | + protected $value; |
|
35 | 35 | |
36 | - /** |
|
37 | - * Creates the property. |
|
38 | - * |
|
39 | - * The constructor value must be one of the |
|
40 | - * \Sabre\DAV\Sharing\Plugin::ACCESS_ constants. |
|
41 | - * |
|
42 | - * @param int $shareAccess |
|
43 | - */ |
|
44 | - public function __construct($shareAccess) |
|
45 | - { |
|
46 | - $this->value = $shareAccess; |
|
47 | - } |
|
36 | + /** |
|
37 | + * Creates the property. |
|
38 | + * |
|
39 | + * The constructor value must be one of the |
|
40 | + * \Sabre\DAV\Sharing\Plugin::ACCESS_ constants. |
|
41 | + * |
|
42 | + * @param int $shareAccess |
|
43 | + */ |
|
44 | + public function __construct($shareAccess) |
|
45 | + { |
|
46 | + $this->value = $shareAccess; |
|
47 | + } |
|
48 | 48 | |
49 | - /** |
|
50 | - * Returns the current value. |
|
51 | - * |
|
52 | - * @return int |
|
53 | - */ |
|
54 | - public function getValue() |
|
55 | - { |
|
56 | - return $this->value; |
|
57 | - } |
|
49 | + /** |
|
50 | + * Returns the current value. |
|
51 | + * |
|
52 | + * @return int |
|
53 | + */ |
|
54 | + public function getValue() |
|
55 | + { |
|
56 | + return $this->value; |
|
57 | + } |
|
58 | 58 | |
59 | - /** |
|
60 | - * The xmlSerialize method is called during xml writing. |
|
61 | - * |
|
62 | - * Use the $writer argument to write its own xml serialization. |
|
63 | - * |
|
64 | - * An important note: do _not_ create a parent element. Any element |
|
65 | - * implementing XmlSerializable should only ever write what's considered |
|
66 | - * its 'inner xml'. |
|
67 | - * |
|
68 | - * The parent of the current element is responsible for writing a |
|
69 | - * containing element. |
|
70 | - * |
|
71 | - * This allows serializers to be re-used for different element names. |
|
72 | - * |
|
73 | - * If you are opening new elements, you must also close them again. |
|
74 | - */ |
|
75 | - public function xmlSerialize(Writer $writer) |
|
76 | - { |
|
77 | - switch ($this->value) { |
|
78 | - case SharingPlugin::ACCESS_NOTSHARED: |
|
79 | - $writer->writeElement('{DAV:}not-shared'); |
|
80 | - break; |
|
81 | - case SharingPlugin::ACCESS_SHAREDOWNER: |
|
82 | - $writer->writeElement('{DAV:}shared-owner'); |
|
83 | - break; |
|
84 | - case SharingPlugin::ACCESS_READ: |
|
85 | - $writer->writeElement('{DAV:}read'); |
|
86 | - break; |
|
87 | - case SharingPlugin::ACCESS_READWRITE: |
|
88 | - $writer->writeElement('{DAV:}read-write'); |
|
89 | - break; |
|
90 | - case SharingPlugin::ACCESS_NOACCESS: |
|
91 | - $writer->writeElement('{DAV:}no-access'); |
|
92 | - break; |
|
93 | - } |
|
94 | - } |
|
59 | + /** |
|
60 | + * The xmlSerialize method is called during xml writing. |
|
61 | + * |
|
62 | + * Use the $writer argument to write its own xml serialization. |
|
63 | + * |
|
64 | + * An important note: do _not_ create a parent element. Any element |
|
65 | + * implementing XmlSerializable should only ever write what's considered |
|
66 | + * its 'inner xml'. |
|
67 | + * |
|
68 | + * The parent of the current element is responsible for writing a |
|
69 | + * containing element. |
|
70 | + * |
|
71 | + * This allows serializers to be re-used for different element names. |
|
72 | + * |
|
73 | + * If you are opening new elements, you must also close them again. |
|
74 | + */ |
|
75 | + public function xmlSerialize(Writer $writer) |
|
76 | + { |
|
77 | + switch ($this->value) { |
|
78 | + case SharingPlugin::ACCESS_NOTSHARED: |
|
79 | + $writer->writeElement('{DAV:}not-shared'); |
|
80 | + break; |
|
81 | + case SharingPlugin::ACCESS_SHAREDOWNER: |
|
82 | + $writer->writeElement('{DAV:}shared-owner'); |
|
83 | + break; |
|
84 | + case SharingPlugin::ACCESS_READ: |
|
85 | + $writer->writeElement('{DAV:}read'); |
|
86 | + break; |
|
87 | + case SharingPlugin::ACCESS_READWRITE: |
|
88 | + $writer->writeElement('{DAV:}read-write'); |
|
89 | + break; |
|
90 | + case SharingPlugin::ACCESS_NOACCESS: |
|
91 | + $writer->writeElement('{DAV:}no-access'); |
|
92 | + break; |
|
93 | + } |
|
94 | + } |
|
95 | 95 | |
96 | - /** |
|
97 | - * The deserialize method is called during xml parsing. |
|
98 | - * |
|
99 | - * This method is called statically, this is because in theory this method |
|
100 | - * may be used as a type of constructor, or factory method. |
|
101 | - * |
|
102 | - * Often you want to return an instance of the current class, but you are |
|
103 | - * free to return other data as well. |
|
104 | - * |
|
105 | - * You are responsible for advancing the reader to the next element. Not |
|
106 | - * doing anything will result in a never-ending loop. |
|
107 | - * |
|
108 | - * If you just want to skip parsing for this element altogether, you can |
|
109 | - * just call $reader->next(); |
|
110 | - * |
|
111 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
112 | - * the next element. |
|
113 | - * |
|
114 | - * @return mixed |
|
115 | - */ |
|
116 | - public static function xmlDeserialize(Reader $reader) |
|
117 | - { |
|
118 | - $elems = $reader->parseInnerTree(); |
|
119 | - foreach ($elems as $elem) { |
|
120 | - switch ($elem['name']) { |
|
121 | - case '{DAV:}not-shared': |
|
122 | - return new self(SharingPlugin::ACCESS_NOTSHARED); |
|
123 | - case '{DAV:}shared-owner': |
|
124 | - return new self(SharingPlugin::ACCESS_SHAREDOWNER); |
|
125 | - case '{DAV:}read': |
|
126 | - return new self(SharingPlugin::ACCESS_READ); |
|
127 | - case '{DAV:}read-write': |
|
128 | - return new self(SharingPlugin::ACCESS_READWRITE); |
|
129 | - case '{DAV:}no-access': |
|
130 | - return new self(SharingPlugin::ACCESS_NOACCESS); |
|
131 | - } |
|
132 | - } |
|
133 | - throw new BadRequest('Invalid value for {DAV:}share-access element'); |
|
134 | - } |
|
96 | + /** |
|
97 | + * The deserialize method is called during xml parsing. |
|
98 | + * |
|
99 | + * This method is called statically, this is because in theory this method |
|
100 | + * may be used as a type of constructor, or factory method. |
|
101 | + * |
|
102 | + * Often you want to return an instance of the current class, but you are |
|
103 | + * free to return other data as well. |
|
104 | + * |
|
105 | + * You are responsible for advancing the reader to the next element. Not |
|
106 | + * doing anything will result in a never-ending loop. |
|
107 | + * |
|
108 | + * If you just want to skip parsing for this element altogether, you can |
|
109 | + * just call $reader->next(); |
|
110 | + * |
|
111 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
112 | + * the next element. |
|
113 | + * |
|
114 | + * @return mixed |
|
115 | + */ |
|
116 | + public static function xmlDeserialize(Reader $reader) |
|
117 | + { |
|
118 | + $elems = $reader->parseInnerTree(); |
|
119 | + foreach ($elems as $elem) { |
|
120 | + switch ($elem['name']) { |
|
121 | + case '{DAV:}not-shared': |
|
122 | + return new self(SharingPlugin::ACCESS_NOTSHARED); |
|
123 | + case '{DAV:}shared-owner': |
|
124 | + return new self(SharingPlugin::ACCESS_SHAREDOWNER); |
|
125 | + case '{DAV:}read': |
|
126 | + return new self(SharingPlugin::ACCESS_READ); |
|
127 | + case '{DAV:}read-write': |
|
128 | + return new self(SharingPlugin::ACCESS_READWRITE); |
|
129 | + case '{DAV:}no-access': |
|
130 | + return new self(SharingPlugin::ACCESS_NOACCESS); |
|
131 | + } |
|
132 | + } |
|
133 | + throw new BadRequest('Invalid value for {DAV:}share-access element'); |
|
134 | + } |
|
135 | 135 | } |