@@ -19,153 +19,153 @@ |
||
| 19 | 19 | */ |
| 20 | 20 | class SystemStatus implements NotificationInterface |
| 21 | 21 | { |
| 22 | - const TYPE_LOW = 1; |
|
| 23 | - const TYPE_MEDIUM = 2; |
|
| 24 | - const TYPE_HIGH = 3; |
|
| 25 | - |
|
| 26 | - /** |
|
| 27 | - * A unique id. |
|
| 28 | - * |
|
| 29 | - * @var string |
|
| 30 | - */ |
|
| 31 | - protected $id; |
|
| 32 | - |
|
| 33 | - /** |
|
| 34 | - * The type of alert. This should be one of the TYPE_ constants. |
|
| 35 | - * |
|
| 36 | - * @var int |
|
| 37 | - */ |
|
| 38 | - protected $type; |
|
| 39 | - |
|
| 40 | - /** |
|
| 41 | - * A human-readable description of the problem. |
|
| 42 | - * |
|
| 43 | - * @var string |
|
| 44 | - */ |
|
| 45 | - protected $description; |
|
| 46 | - |
|
| 47 | - /** |
|
| 48 | - * A url to a website with more information for the user. |
|
| 49 | - * |
|
| 50 | - * @var string |
|
| 51 | - */ |
|
| 52 | - protected $href; |
|
| 53 | - |
|
| 54 | - /** |
|
| 55 | - * Notification Etag. |
|
| 56 | - * |
|
| 57 | - * @var string |
|
| 58 | - */ |
|
| 59 | - protected $etag; |
|
| 60 | - |
|
| 61 | - /** |
|
| 62 | - * Creates the notification. |
|
| 63 | - * |
|
| 64 | - * Some kind of unique id should be provided. This is used to generate a |
|
| 65 | - * url. |
|
| 66 | - * |
|
| 67 | - * @param string $id |
|
| 68 | - * @param string $etag |
|
| 69 | - * @param int $type |
|
| 70 | - * @param string $description |
|
| 71 | - * @param string $href |
|
| 72 | - */ |
|
| 73 | - public function __construct($id, $etag, $type = self::TYPE_HIGH, $description = null, $href = null) |
|
| 74 | - { |
|
| 75 | - $this->id = $id; |
|
| 76 | - $this->type = $type; |
|
| 77 | - $this->description = $description; |
|
| 78 | - $this->href = $href; |
|
| 79 | - $this->etag = $etag; |
|
| 80 | - } |
|
| 81 | - |
|
| 82 | - /** |
|
| 83 | - * The serialize method is called during xml writing. |
|
| 84 | - * |
|
| 85 | - * It should use the $writer argument to encode this object into XML. |
|
| 86 | - * |
|
| 87 | - * Important note: it is not needed to create the parent element. The |
|
| 88 | - * parent element is already created, and we only have to worry about |
|
| 89 | - * attributes, child elements and text (if any). |
|
| 90 | - * |
|
| 91 | - * Important note 2: If you are writing any new elements, you are also |
|
| 92 | - * responsible for closing them. |
|
| 93 | - */ |
|
| 94 | - public function xmlSerialize(Writer $writer) |
|
| 95 | - { |
|
| 96 | - switch ($this->type) { |
|
| 97 | - case self::TYPE_LOW: |
|
| 98 | - $type = 'low'; |
|
| 99 | - break; |
|
| 100 | - case self::TYPE_MEDIUM: |
|
| 101 | - $type = 'medium'; |
|
| 102 | - break; |
|
| 103 | - default: |
|
| 104 | - case self::TYPE_HIGH: |
|
| 105 | - $type = 'high'; |
|
| 106 | - break; |
|
| 107 | - } |
|
| 108 | - |
|
| 109 | - $writer->startElement('{'.Plugin::NS_CALENDARSERVER.'}systemstatus'); |
|
| 110 | - $writer->writeAttribute('type', $type); |
|
| 111 | - $writer->endElement(); |
|
| 112 | - } |
|
| 113 | - |
|
| 114 | - /** |
|
| 115 | - * This method serializes the entire notification, as it is used in the |
|
| 116 | - * response body. |
|
| 117 | - */ |
|
| 118 | - public function xmlSerializeFull(Writer $writer) |
|
| 119 | - { |
|
| 120 | - $cs = '{'.Plugin::NS_CALENDARSERVER.'}'; |
|
| 121 | - switch ($this->type) { |
|
| 122 | - case self::TYPE_LOW: |
|
| 123 | - $type = 'low'; |
|
| 124 | - break; |
|
| 125 | - case self::TYPE_MEDIUM: |
|
| 126 | - $type = 'medium'; |
|
| 127 | - break; |
|
| 128 | - default: |
|
| 129 | - case self::TYPE_HIGH: |
|
| 130 | - $type = 'high'; |
|
| 131 | - break; |
|
| 132 | - } |
|
| 133 | - |
|
| 134 | - $writer->startElement($cs.'systemstatus'); |
|
| 135 | - $writer->writeAttribute('type', $type); |
|
| 136 | - |
|
| 137 | - if ($this->description) { |
|
| 138 | - $writer->writeElement($cs.'description', $this->description); |
|
| 139 | - } |
|
| 140 | - if ($this->href) { |
|
| 141 | - $writer->writeElement('{DAV:}href', $this->href); |
|
| 142 | - } |
|
| 143 | - |
|
| 144 | - $writer->endElement(); // systemstatus |
|
| 145 | - } |
|
| 146 | - |
|
| 147 | - /** |
|
| 148 | - * Returns a unique id for this notification. |
|
| 149 | - * |
|
| 150 | - * This is just the base url. This should generally be some kind of unique |
|
| 151 | - * id. |
|
| 152 | - * |
|
| 153 | - * @return string |
|
| 154 | - */ |
|
| 155 | - public function getId() |
|
| 156 | - { |
|
| 157 | - return $this->id; |
|
| 158 | - } |
|
| 159 | - |
|
| 160 | - /* |
|
| 22 | + const TYPE_LOW = 1; |
|
| 23 | + const TYPE_MEDIUM = 2; |
|
| 24 | + const TYPE_HIGH = 3; |
|
| 25 | + |
|
| 26 | + /** |
|
| 27 | + * A unique id. |
|
| 28 | + * |
|
| 29 | + * @var string |
|
| 30 | + */ |
|
| 31 | + protected $id; |
|
| 32 | + |
|
| 33 | + /** |
|
| 34 | + * The type of alert. This should be one of the TYPE_ constants. |
|
| 35 | + * |
|
| 36 | + * @var int |
|
| 37 | + */ |
|
| 38 | + protected $type; |
|
| 39 | + |
|
| 40 | + /** |
|
| 41 | + * A human-readable description of the problem. |
|
| 42 | + * |
|
| 43 | + * @var string |
|
| 44 | + */ |
|
| 45 | + protected $description; |
|
| 46 | + |
|
| 47 | + /** |
|
| 48 | + * A url to a website with more information for the user. |
|
| 49 | + * |
|
| 50 | + * @var string |
|
| 51 | + */ |
|
| 52 | + protected $href; |
|
| 53 | + |
|
| 54 | + /** |
|
| 55 | + * Notification Etag. |
|
| 56 | + * |
|
| 57 | + * @var string |
|
| 58 | + */ |
|
| 59 | + protected $etag; |
|
| 60 | + |
|
| 61 | + /** |
|
| 62 | + * Creates the notification. |
|
| 63 | + * |
|
| 64 | + * Some kind of unique id should be provided. This is used to generate a |
|
| 65 | + * url. |
|
| 66 | + * |
|
| 67 | + * @param string $id |
|
| 68 | + * @param string $etag |
|
| 69 | + * @param int $type |
|
| 70 | + * @param string $description |
|
| 71 | + * @param string $href |
|
| 72 | + */ |
|
| 73 | + public function __construct($id, $etag, $type = self::TYPE_HIGH, $description = null, $href = null) |
|
| 74 | + { |
|
| 75 | + $this->id = $id; |
|
| 76 | + $this->type = $type; |
|
| 77 | + $this->description = $description; |
|
| 78 | + $this->href = $href; |
|
| 79 | + $this->etag = $etag; |
|
| 80 | + } |
|
| 81 | + |
|
| 82 | + /** |
|
| 83 | + * The serialize method is called during xml writing. |
|
| 84 | + * |
|
| 85 | + * It should use the $writer argument to encode this object into XML. |
|
| 86 | + * |
|
| 87 | + * Important note: it is not needed to create the parent element. The |
|
| 88 | + * parent element is already created, and we only have to worry about |
|
| 89 | + * attributes, child elements and text (if any). |
|
| 90 | + * |
|
| 91 | + * Important note 2: If you are writing any new elements, you are also |
|
| 92 | + * responsible for closing them. |
|
| 93 | + */ |
|
| 94 | + public function xmlSerialize(Writer $writer) |
|
| 95 | + { |
|
| 96 | + switch ($this->type) { |
|
| 97 | + case self::TYPE_LOW: |
|
| 98 | + $type = 'low'; |
|
| 99 | + break; |
|
| 100 | + case self::TYPE_MEDIUM: |
|
| 101 | + $type = 'medium'; |
|
| 102 | + break; |
|
| 103 | + default: |
|
| 104 | + case self::TYPE_HIGH: |
|
| 105 | + $type = 'high'; |
|
| 106 | + break; |
|
| 107 | + } |
|
| 108 | + |
|
| 109 | + $writer->startElement('{'.Plugin::NS_CALENDARSERVER.'}systemstatus'); |
|
| 110 | + $writer->writeAttribute('type', $type); |
|
| 111 | + $writer->endElement(); |
|
| 112 | + } |
|
| 113 | + |
|
| 114 | + /** |
|
| 115 | + * This method serializes the entire notification, as it is used in the |
|
| 116 | + * response body. |
|
| 117 | + */ |
|
| 118 | + public function xmlSerializeFull(Writer $writer) |
|
| 119 | + { |
|
| 120 | + $cs = '{'.Plugin::NS_CALENDARSERVER.'}'; |
|
| 121 | + switch ($this->type) { |
|
| 122 | + case self::TYPE_LOW: |
|
| 123 | + $type = 'low'; |
|
| 124 | + break; |
|
| 125 | + case self::TYPE_MEDIUM: |
|
| 126 | + $type = 'medium'; |
|
| 127 | + break; |
|
| 128 | + default: |
|
| 129 | + case self::TYPE_HIGH: |
|
| 130 | + $type = 'high'; |
|
| 131 | + break; |
|
| 132 | + } |
|
| 133 | + |
|
| 134 | + $writer->startElement($cs.'systemstatus'); |
|
| 135 | + $writer->writeAttribute('type', $type); |
|
| 136 | + |
|
| 137 | + if ($this->description) { |
|
| 138 | + $writer->writeElement($cs.'description', $this->description); |
|
| 139 | + } |
|
| 140 | + if ($this->href) { |
|
| 141 | + $writer->writeElement('{DAV:}href', $this->href); |
|
| 142 | + } |
|
| 143 | + |
|
| 144 | + $writer->endElement(); // systemstatus |
|
| 145 | + } |
|
| 146 | + |
|
| 147 | + /** |
|
| 148 | + * Returns a unique id for this notification. |
|
| 149 | + * |
|
| 150 | + * This is just the base url. This should generally be some kind of unique |
|
| 151 | + * id. |
|
| 152 | + * |
|
| 153 | + * @return string |
|
| 154 | + */ |
|
| 155 | + public function getId() |
|
| 156 | + { |
|
| 157 | + return $this->id; |
|
| 158 | + } |
|
| 159 | + |
|
| 160 | + /* |
|
| 161 | 161 | * Returns the ETag for this notification. |
| 162 | 162 | * |
| 163 | 163 | * The ETag must be surrounded by literal double-quotes. |
| 164 | 164 | * |
| 165 | 165 | * @return string |
| 166 | 166 | */ |
| 167 | - public function getETag() |
|
| 168 | - { |
|
| 169 | - return $this->etag; |
|
| 170 | - } |
|
| 167 | + public function getETag() |
|
| 168 | + { |
|
| 169 | + return $this->etag; |
|
| 170 | + } |
|
| 171 | 171 | } |
@@ -18,182 +18,182 @@ |
||
| 18 | 18 | */ |
| 19 | 19 | class InviteReply implements NotificationInterface |
| 20 | 20 | { |
| 21 | - /** |
|
| 22 | - * A unique id for the message. |
|
| 23 | - * |
|
| 24 | - * @var string |
|
| 25 | - */ |
|
| 26 | - protected $id; |
|
| 27 | - |
|
| 28 | - /** |
|
| 29 | - * Timestamp of the notification. |
|
| 30 | - * |
|
| 31 | - * @var \DateTime |
|
| 32 | - */ |
|
| 33 | - protected $dtStamp; |
|
| 34 | - |
|
| 35 | - /** |
|
| 36 | - * The unique id of the notification this was a reply to. |
|
| 37 | - * |
|
| 38 | - * @var string |
|
| 39 | - */ |
|
| 40 | - protected $inReplyTo; |
|
| 41 | - |
|
| 42 | - /** |
|
| 43 | - * A url to the recipient of the original (!) notification. |
|
| 44 | - * |
|
| 45 | - * @var string |
|
| 46 | - */ |
|
| 47 | - protected $href; |
|
| 48 | - |
|
| 49 | - /** |
|
| 50 | - * The type of message, see the SharingPlugin::STATUS_ constants. |
|
| 51 | - * |
|
| 52 | - * @var int |
|
| 53 | - */ |
|
| 54 | - protected $type; |
|
| 55 | - |
|
| 56 | - /** |
|
| 57 | - * A url to the shared calendar. |
|
| 58 | - * |
|
| 59 | - * @var string |
|
| 60 | - */ |
|
| 61 | - protected $hostUrl; |
|
| 62 | - |
|
| 63 | - /** |
|
| 64 | - * A description of the share request. |
|
| 65 | - * |
|
| 66 | - * @var string |
|
| 67 | - */ |
|
| 68 | - protected $summary; |
|
| 69 | - |
|
| 70 | - /** |
|
| 71 | - * Notification Etag. |
|
| 72 | - * |
|
| 73 | - * @var string |
|
| 74 | - */ |
|
| 75 | - protected $etag; |
|
| 76 | - |
|
| 77 | - /** |
|
| 78 | - * Creates the Invite Reply Notification. |
|
| 79 | - * |
|
| 80 | - * This constructor receives an array with the following elements: |
|
| 81 | - * |
|
| 82 | - * * id - A unique id |
|
| 83 | - * * etag - The etag |
|
| 84 | - * * dtStamp - A DateTime object with a timestamp for the notification. |
|
| 85 | - * * inReplyTo - This should refer to the 'id' of the notification |
|
| 86 | - * this is a reply to. |
|
| 87 | - * * type - The type of notification, see SharingPlugin::STATUS_* |
|
| 88 | - * constants for details. |
|
| 89 | - * * hostUrl - A url to the shared calendar. |
|
| 90 | - * * summary - Description of the share, can be the same as the |
|
| 91 | - * calendar, but may also be modified (optional). |
|
| 92 | - */ |
|
| 93 | - public function __construct(array $values) |
|
| 94 | - { |
|
| 95 | - $required = [ |
|
| 96 | - 'id', |
|
| 97 | - 'etag', |
|
| 98 | - 'href', |
|
| 99 | - 'dtStamp', |
|
| 100 | - 'inReplyTo', |
|
| 101 | - 'type', |
|
| 102 | - 'hostUrl', |
|
| 103 | - ]; |
|
| 104 | - foreach ($required as $item) { |
|
| 105 | - if (!isset($values[$item])) { |
|
| 106 | - throw new \InvalidArgumentException($item.' is a required constructor option'); |
|
| 107 | - } |
|
| 108 | - } |
|
| 109 | - |
|
| 110 | - foreach ($values as $key => $value) { |
|
| 111 | - if (!property_exists($this, $key)) { |
|
| 112 | - throw new \InvalidArgumentException('Unknown option: '.$key); |
|
| 113 | - } |
|
| 114 | - $this->$key = $value; |
|
| 115 | - } |
|
| 116 | - } |
|
| 117 | - |
|
| 118 | - /** |
|
| 119 | - * The xmlSerialize method is called during xml writing. |
|
| 120 | - * |
|
| 121 | - * Use the $writer argument to write its own xml serialization. |
|
| 122 | - * |
|
| 123 | - * An important note: do _not_ create a parent element. Any element |
|
| 124 | - * implementing XmlSerializable should only ever write what's considered |
|
| 125 | - * its 'inner xml'. |
|
| 126 | - * |
|
| 127 | - * The parent of the current element is responsible for writing a |
|
| 128 | - * containing element. |
|
| 129 | - * |
|
| 130 | - * This allows serializers to be re-used for different element names. |
|
| 131 | - * |
|
| 132 | - * If you are opening new elements, you must also close them again. |
|
| 133 | - */ |
|
| 134 | - public function xmlSerialize(Writer $writer) |
|
| 135 | - { |
|
| 136 | - $writer->writeElement('{'.CalDAV\Plugin::NS_CALENDARSERVER.'}invite-reply'); |
|
| 137 | - } |
|
| 138 | - |
|
| 139 | - /** |
|
| 140 | - * This method serializes the entire notification, as it is used in the |
|
| 141 | - * response body. |
|
| 142 | - */ |
|
| 143 | - public function xmlSerializeFull(Writer $writer) |
|
| 144 | - { |
|
| 145 | - $cs = '{'.CalDAV\Plugin::NS_CALENDARSERVER.'}'; |
|
| 146 | - |
|
| 147 | - $this->dtStamp->setTimezone(new \DateTimeZone('GMT')); |
|
| 148 | - $writer->writeElement($cs.'dtstamp', $this->dtStamp->format('Ymd\\THis\\Z')); |
|
| 149 | - |
|
| 150 | - $writer->startElement($cs.'invite-reply'); |
|
| 151 | - |
|
| 152 | - $writer->writeElement($cs.'uid', $this->id); |
|
| 153 | - $writer->writeElement($cs.'in-reply-to', $this->inReplyTo); |
|
| 154 | - $writer->writeElement('{DAV:}href', $this->href); |
|
| 155 | - |
|
| 156 | - switch ($this->type) { |
|
| 157 | - case DAV\Sharing\Plugin::INVITE_ACCEPTED: |
|
| 158 | - $writer->writeElement($cs.'invite-accepted'); |
|
| 159 | - break; |
|
| 160 | - case DAV\Sharing\Plugin::INVITE_DECLINED: |
|
| 161 | - $writer->writeElement($cs.'invite-declined'); |
|
| 162 | - break; |
|
| 163 | - } |
|
| 164 | - |
|
| 165 | - $writer->writeElement($cs.'hosturl', [ |
|
| 166 | - '{DAV:}href' => $writer->contextUri.$this->hostUrl, |
|
| 167 | - ]); |
|
| 168 | - |
|
| 169 | - if ($this->summary) { |
|
| 170 | - $writer->writeElement($cs.'summary', $this->summary); |
|
| 171 | - } |
|
| 172 | - $writer->endElement(); // invite-reply |
|
| 173 | - } |
|
| 174 | - |
|
| 175 | - /** |
|
| 176 | - * Returns a unique id for this notification. |
|
| 177 | - * |
|
| 178 | - * This is just the base url. This should generally be some kind of unique |
|
| 179 | - * id. |
|
| 180 | - * |
|
| 181 | - * @return string |
|
| 182 | - */ |
|
| 183 | - public function getId() |
|
| 184 | - { |
|
| 185 | - return $this->id; |
|
| 186 | - } |
|
| 187 | - |
|
| 188 | - /** |
|
| 189 | - * Returns the ETag for this notification. |
|
| 190 | - * |
|
| 191 | - * The ETag must be surrounded by literal double-quotes. |
|
| 192 | - * |
|
| 193 | - * @return string |
|
| 194 | - */ |
|
| 195 | - public function getETag() |
|
| 196 | - { |
|
| 197 | - return $this->etag; |
|
| 198 | - } |
|
| 21 | + /** |
|
| 22 | + * A unique id for the message. |
|
| 23 | + * |
|
| 24 | + * @var string |
|
| 25 | + */ |
|
| 26 | + protected $id; |
|
| 27 | + |
|
| 28 | + /** |
|
| 29 | + * Timestamp of the notification. |
|
| 30 | + * |
|
| 31 | + * @var \DateTime |
|
| 32 | + */ |
|
| 33 | + protected $dtStamp; |
|
| 34 | + |
|
| 35 | + /** |
|
| 36 | + * The unique id of the notification this was a reply to. |
|
| 37 | + * |
|
| 38 | + * @var string |
|
| 39 | + */ |
|
| 40 | + protected $inReplyTo; |
|
| 41 | + |
|
| 42 | + /** |
|
| 43 | + * A url to the recipient of the original (!) notification. |
|
| 44 | + * |
|
| 45 | + * @var string |
|
| 46 | + */ |
|
| 47 | + protected $href; |
|
| 48 | + |
|
| 49 | + /** |
|
| 50 | + * The type of message, see the SharingPlugin::STATUS_ constants. |
|
| 51 | + * |
|
| 52 | + * @var int |
|
| 53 | + */ |
|
| 54 | + protected $type; |
|
| 55 | + |
|
| 56 | + /** |
|
| 57 | + * A url to the shared calendar. |
|
| 58 | + * |
|
| 59 | + * @var string |
|
| 60 | + */ |
|
| 61 | + protected $hostUrl; |
|
| 62 | + |
|
| 63 | + /** |
|
| 64 | + * A description of the share request. |
|
| 65 | + * |
|
| 66 | + * @var string |
|
| 67 | + */ |
|
| 68 | + protected $summary; |
|
| 69 | + |
|
| 70 | + /** |
|
| 71 | + * Notification Etag. |
|
| 72 | + * |
|
| 73 | + * @var string |
|
| 74 | + */ |
|
| 75 | + protected $etag; |
|
| 76 | + |
|
| 77 | + /** |
|
| 78 | + * Creates the Invite Reply Notification. |
|
| 79 | + * |
|
| 80 | + * This constructor receives an array with the following elements: |
|
| 81 | + * |
|
| 82 | + * * id - A unique id |
|
| 83 | + * * etag - The etag |
|
| 84 | + * * dtStamp - A DateTime object with a timestamp for the notification. |
|
| 85 | + * * inReplyTo - This should refer to the 'id' of the notification |
|
| 86 | + * this is a reply to. |
|
| 87 | + * * type - The type of notification, see SharingPlugin::STATUS_* |
|
| 88 | + * constants for details. |
|
| 89 | + * * hostUrl - A url to the shared calendar. |
|
| 90 | + * * summary - Description of the share, can be the same as the |
|
| 91 | + * calendar, but may also be modified (optional). |
|
| 92 | + */ |
|
| 93 | + public function __construct(array $values) |
|
| 94 | + { |
|
| 95 | + $required = [ |
|
| 96 | + 'id', |
|
| 97 | + 'etag', |
|
| 98 | + 'href', |
|
| 99 | + 'dtStamp', |
|
| 100 | + 'inReplyTo', |
|
| 101 | + 'type', |
|
| 102 | + 'hostUrl', |
|
| 103 | + ]; |
|
| 104 | + foreach ($required as $item) { |
|
| 105 | + if (!isset($values[$item])) { |
|
| 106 | + throw new \InvalidArgumentException($item.' is a required constructor option'); |
|
| 107 | + } |
|
| 108 | + } |
|
| 109 | + |
|
| 110 | + foreach ($values as $key => $value) { |
|
| 111 | + if (!property_exists($this, $key)) { |
|
| 112 | + throw new \InvalidArgumentException('Unknown option: '.$key); |
|
| 113 | + } |
|
| 114 | + $this->$key = $value; |
|
| 115 | + } |
|
| 116 | + } |
|
| 117 | + |
|
| 118 | + /** |
|
| 119 | + * The xmlSerialize method is called during xml writing. |
|
| 120 | + * |
|
| 121 | + * Use the $writer argument to write its own xml serialization. |
|
| 122 | + * |
|
| 123 | + * An important note: do _not_ create a parent element. Any element |
|
| 124 | + * implementing XmlSerializable should only ever write what's considered |
|
| 125 | + * its 'inner xml'. |
|
| 126 | + * |
|
| 127 | + * The parent of the current element is responsible for writing a |
|
| 128 | + * containing element. |
|
| 129 | + * |
|
| 130 | + * This allows serializers to be re-used for different element names. |
|
| 131 | + * |
|
| 132 | + * If you are opening new elements, you must also close them again. |
|
| 133 | + */ |
|
| 134 | + public function xmlSerialize(Writer $writer) |
|
| 135 | + { |
|
| 136 | + $writer->writeElement('{'.CalDAV\Plugin::NS_CALENDARSERVER.'}invite-reply'); |
|
| 137 | + } |
|
| 138 | + |
|
| 139 | + /** |
|
| 140 | + * This method serializes the entire notification, as it is used in the |
|
| 141 | + * response body. |
|
| 142 | + */ |
|
| 143 | + public function xmlSerializeFull(Writer $writer) |
|
| 144 | + { |
|
| 145 | + $cs = '{'.CalDAV\Plugin::NS_CALENDARSERVER.'}'; |
|
| 146 | + |
|
| 147 | + $this->dtStamp->setTimezone(new \DateTimeZone('GMT')); |
|
| 148 | + $writer->writeElement($cs.'dtstamp', $this->dtStamp->format('Ymd\\THis\\Z')); |
|
| 149 | + |
|
| 150 | + $writer->startElement($cs.'invite-reply'); |
|
| 151 | + |
|
| 152 | + $writer->writeElement($cs.'uid', $this->id); |
|
| 153 | + $writer->writeElement($cs.'in-reply-to', $this->inReplyTo); |
|
| 154 | + $writer->writeElement('{DAV:}href', $this->href); |
|
| 155 | + |
|
| 156 | + switch ($this->type) { |
|
| 157 | + case DAV\Sharing\Plugin::INVITE_ACCEPTED: |
|
| 158 | + $writer->writeElement($cs.'invite-accepted'); |
|
| 159 | + break; |
|
| 160 | + case DAV\Sharing\Plugin::INVITE_DECLINED: |
|
| 161 | + $writer->writeElement($cs.'invite-declined'); |
|
| 162 | + break; |
|
| 163 | + } |
|
| 164 | + |
|
| 165 | + $writer->writeElement($cs.'hosturl', [ |
|
| 166 | + '{DAV:}href' => $writer->contextUri.$this->hostUrl, |
|
| 167 | + ]); |
|
| 168 | + |
|
| 169 | + if ($this->summary) { |
|
| 170 | + $writer->writeElement($cs.'summary', $this->summary); |
|
| 171 | + } |
|
| 172 | + $writer->endElement(); // invite-reply |
|
| 173 | + } |
|
| 174 | + |
|
| 175 | + /** |
|
| 176 | + * Returns a unique id for this notification. |
|
| 177 | + * |
|
| 178 | + * This is just the base url. This should generally be some kind of unique |
|
| 179 | + * id. |
|
| 180 | + * |
|
| 181 | + * @return string |
|
| 182 | + */ |
|
| 183 | + public function getId() |
|
| 184 | + { |
|
| 185 | + return $this->id; |
|
| 186 | + } |
|
| 187 | + |
|
| 188 | + /** |
|
| 189 | + * Returns the ETag for this notification. |
|
| 190 | + * |
|
| 191 | + * The ETag must be surrounded by literal double-quotes. |
|
| 192 | + * |
|
| 193 | + * @return string |
|
| 194 | + */ |
|
| 195 | + public function getETag() |
|
| 196 | + { |
|
| 197 | + return $this->etag; |
|
| 198 | + } |
|
| 199 | 199 | } |
@@ -16,28 +16,28 @@ |
||
| 16 | 16 | */ |
| 17 | 17 | interface NotificationInterface extends XmlSerializable |
| 18 | 18 | { |
| 19 | - /** |
|
| 20 | - * This method serializes the entire notification, as it is used in the |
|
| 21 | - * response body. |
|
| 22 | - */ |
|
| 23 | - public function xmlSerializeFull(Writer $writer); |
|
| 19 | + /** |
|
| 20 | + * This method serializes the entire notification, as it is used in the |
|
| 21 | + * response body. |
|
| 22 | + */ |
|
| 23 | + public function xmlSerializeFull(Writer $writer); |
|
| 24 | 24 | |
| 25 | - /** |
|
| 26 | - * Returns a unique id for this notification. |
|
| 27 | - * |
|
| 28 | - * This is just the base url. This should generally be some kind of unique |
|
| 29 | - * id. |
|
| 30 | - * |
|
| 31 | - * @return string |
|
| 32 | - */ |
|
| 33 | - public function getId(); |
|
| 25 | + /** |
|
| 26 | + * Returns a unique id for this notification. |
|
| 27 | + * |
|
| 28 | + * This is just the base url. This should generally be some kind of unique |
|
| 29 | + * id. |
|
| 30 | + * |
|
| 31 | + * @return string |
|
| 32 | + */ |
|
| 33 | + public function getId(); |
|
| 34 | 34 | |
| 35 | - /** |
|
| 36 | - * Returns the ETag for this notification. |
|
| 37 | - * |
|
| 38 | - * The ETag must be surrounded by literal double-quotes. |
|
| 39 | - * |
|
| 40 | - * @return string |
|
| 41 | - */ |
|
| 42 | - public function getETag(); |
|
| 35 | + /** |
|
| 36 | + * Returns the ETag for this notification. |
|
| 37 | + * |
|
| 38 | + * The ETag must be surrounded by literal double-quotes. |
|
| 39 | + * |
|
| 40 | + * @return string |
|
| 41 | + */ |
|
| 42 | + public function getETag(); |
|
| 43 | 43 | } |
@@ -25,121 +25,121 @@ |
||
| 25 | 25 | */ |
| 26 | 26 | class InviteReply implements XmlDeserializable |
| 27 | 27 | { |
| 28 | - /** |
|
| 29 | - * The sharee calendar user address. |
|
| 30 | - * |
|
| 31 | - * This is the address that the original invite was set to |
|
| 32 | - * |
|
| 33 | - * @var string |
|
| 34 | - */ |
|
| 35 | - public $href; |
|
| 28 | + /** |
|
| 29 | + * The sharee calendar user address. |
|
| 30 | + * |
|
| 31 | + * This is the address that the original invite was set to |
|
| 32 | + * |
|
| 33 | + * @var string |
|
| 34 | + */ |
|
| 35 | + public $href; |
|
| 36 | 36 | |
| 37 | - /** |
|
| 38 | - * The uri to the calendar that was being shared. |
|
| 39 | - * |
|
| 40 | - * @var string |
|
| 41 | - */ |
|
| 42 | - public $calendarUri; |
|
| 37 | + /** |
|
| 38 | + * The uri to the calendar that was being shared. |
|
| 39 | + * |
|
| 40 | + * @var string |
|
| 41 | + */ |
|
| 42 | + public $calendarUri; |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * The id of the invite message that's being responded to. |
|
| 46 | - * |
|
| 47 | - * @var string |
|
| 48 | - */ |
|
| 49 | - public $inReplyTo; |
|
| 44 | + /** |
|
| 45 | + * The id of the invite message that's being responded to. |
|
| 46 | + * |
|
| 47 | + * @var string |
|
| 48 | + */ |
|
| 49 | + public $inReplyTo; |
|
| 50 | 50 | |
| 51 | - /** |
|
| 52 | - * An optional message. |
|
| 53 | - * |
|
| 54 | - * @var string |
|
| 55 | - */ |
|
| 56 | - public $summary; |
|
| 51 | + /** |
|
| 52 | + * An optional message. |
|
| 53 | + * |
|
| 54 | + * @var string |
|
| 55 | + */ |
|
| 56 | + public $summary; |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * Either SharingPlugin::STATUS_ACCEPTED or SharingPlugin::STATUS_DECLINED. |
|
| 60 | - * |
|
| 61 | - * @var int |
|
| 62 | - */ |
|
| 63 | - public $status; |
|
| 58 | + /** |
|
| 59 | + * Either SharingPlugin::STATUS_ACCEPTED or SharingPlugin::STATUS_DECLINED. |
|
| 60 | + * |
|
| 61 | + * @var int |
|
| 62 | + */ |
|
| 63 | + public $status; |
|
| 64 | 64 | |
| 65 | - /** |
|
| 66 | - * Constructor. |
|
| 67 | - * |
|
| 68 | - * @param string $href |
|
| 69 | - * @param string $calendarUri |
|
| 70 | - * @param string $inReplyTo |
|
| 71 | - * @param string $summary |
|
| 72 | - * @param int $status |
|
| 73 | - */ |
|
| 74 | - public function __construct($href, $calendarUri, $inReplyTo, $summary, $status) |
|
| 75 | - { |
|
| 76 | - $this->href = $href; |
|
| 77 | - $this->calendarUri = $calendarUri; |
|
| 78 | - $this->inReplyTo = $inReplyTo; |
|
| 79 | - $this->summary = $summary; |
|
| 80 | - $this->status = $status; |
|
| 81 | - } |
|
| 65 | + /** |
|
| 66 | + * Constructor. |
|
| 67 | + * |
|
| 68 | + * @param string $href |
|
| 69 | + * @param string $calendarUri |
|
| 70 | + * @param string $inReplyTo |
|
| 71 | + * @param string $summary |
|
| 72 | + * @param int $status |
|
| 73 | + */ |
|
| 74 | + public function __construct($href, $calendarUri, $inReplyTo, $summary, $status) |
|
| 75 | + { |
|
| 76 | + $this->href = $href; |
|
| 77 | + $this->calendarUri = $calendarUri; |
|
| 78 | + $this->inReplyTo = $inReplyTo; |
|
| 79 | + $this->summary = $summary; |
|
| 80 | + $this->status = $status; |
|
| 81 | + } |
|
| 82 | 82 | |
| 83 | - /** |
|
| 84 | - * The deserialize method is called during xml parsing. |
|
| 85 | - * |
|
| 86 | - * This method is called statically, this is because in theory this method |
|
| 87 | - * may be used as a type of constructor, or factory method. |
|
| 88 | - * |
|
| 89 | - * Often you want to return an instance of the current class, but you are |
|
| 90 | - * free to return other data as well. |
|
| 91 | - * |
|
| 92 | - * You are responsible for advancing the reader to the next element. Not |
|
| 93 | - * doing anything will result in a never-ending loop. |
|
| 94 | - * |
|
| 95 | - * If you just want to skip parsing for this element altogether, you can |
|
| 96 | - * just call $reader->next(); |
|
| 97 | - * |
|
| 98 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
| 99 | - * the next element. |
|
| 100 | - * |
|
| 101 | - * @return mixed |
|
| 102 | - */ |
|
| 103 | - public static function xmlDeserialize(Reader $reader) |
|
| 104 | - { |
|
| 105 | - $elems = KeyValue::xmlDeserialize($reader); |
|
| 83 | + /** |
|
| 84 | + * The deserialize method is called during xml parsing. |
|
| 85 | + * |
|
| 86 | + * This method is called statically, this is because in theory this method |
|
| 87 | + * may be used as a type of constructor, or factory method. |
|
| 88 | + * |
|
| 89 | + * Often you want to return an instance of the current class, but you are |
|
| 90 | + * free to return other data as well. |
|
| 91 | + * |
|
| 92 | + * You are responsible for advancing the reader to the next element. Not |
|
| 93 | + * doing anything will result in a never-ending loop. |
|
| 94 | + * |
|
| 95 | + * If you just want to skip parsing for this element altogether, you can |
|
| 96 | + * just call $reader->next(); |
|
| 97 | + * |
|
| 98 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
| 99 | + * the next element. |
|
| 100 | + * |
|
| 101 | + * @return mixed |
|
| 102 | + */ |
|
| 103 | + public static function xmlDeserialize(Reader $reader) |
|
| 104 | + { |
|
| 105 | + $elems = KeyValue::xmlDeserialize($reader); |
|
| 106 | 106 | |
| 107 | - $href = null; |
|
| 108 | - $calendarUri = null; |
|
| 109 | - $inReplyTo = null; |
|
| 110 | - $summary = null; |
|
| 111 | - $status = null; |
|
| 107 | + $href = null; |
|
| 108 | + $calendarUri = null; |
|
| 109 | + $inReplyTo = null; |
|
| 110 | + $summary = null; |
|
| 111 | + $status = null; |
|
| 112 | 112 | |
| 113 | - foreach ($elems as $name => $value) { |
|
| 114 | - switch ($name) { |
|
| 115 | - case '{'.Plugin::NS_CALENDARSERVER.'}hosturl': |
|
| 116 | - foreach ($value as $bla) { |
|
| 117 | - if ('{DAV:}href' === $bla['name']) { |
|
| 118 | - $calendarUri = $bla['value']; |
|
| 119 | - } |
|
| 120 | - } |
|
| 121 | - break; |
|
| 122 | - case '{'.Plugin::NS_CALENDARSERVER.'}invite-accepted': |
|
| 123 | - $status = DAV\Sharing\Plugin::INVITE_ACCEPTED; |
|
| 124 | - break; |
|
| 125 | - case '{'.Plugin::NS_CALENDARSERVER.'}invite-declined': |
|
| 126 | - $status = DAV\Sharing\Plugin::INVITE_DECLINED; |
|
| 127 | - break; |
|
| 128 | - case '{'.Plugin::NS_CALENDARSERVER.'}in-reply-to': |
|
| 129 | - $inReplyTo = $value; |
|
| 130 | - break; |
|
| 131 | - case '{'.Plugin::NS_CALENDARSERVER.'}summary': |
|
| 132 | - $summary = $value; |
|
| 133 | - break; |
|
| 134 | - case '{DAV:}href': |
|
| 135 | - $href = $value; |
|
| 136 | - break; |
|
| 137 | - } |
|
| 138 | - } |
|
| 139 | - if (is_null($calendarUri)) { |
|
| 140 | - throw new BadRequest('The {http://calendarserver.org/ns/}hosturl/{DAV:}href element must exist'); |
|
| 141 | - } |
|
| 113 | + foreach ($elems as $name => $value) { |
|
| 114 | + switch ($name) { |
|
| 115 | + case '{'.Plugin::NS_CALENDARSERVER.'}hosturl': |
|
| 116 | + foreach ($value as $bla) { |
|
| 117 | + if ('{DAV:}href' === $bla['name']) { |
|
| 118 | + $calendarUri = $bla['value']; |
|
| 119 | + } |
|
| 120 | + } |
|
| 121 | + break; |
|
| 122 | + case '{'.Plugin::NS_CALENDARSERVER.'}invite-accepted': |
|
| 123 | + $status = DAV\Sharing\Plugin::INVITE_ACCEPTED; |
|
| 124 | + break; |
|
| 125 | + case '{'.Plugin::NS_CALENDARSERVER.'}invite-declined': |
|
| 126 | + $status = DAV\Sharing\Plugin::INVITE_DECLINED; |
|
| 127 | + break; |
|
| 128 | + case '{'.Plugin::NS_CALENDARSERVER.'}in-reply-to': |
|
| 129 | + $inReplyTo = $value; |
|
| 130 | + break; |
|
| 131 | + case '{'.Plugin::NS_CALENDARSERVER.'}summary': |
|
| 132 | + $summary = $value; |
|
| 133 | + break; |
|
| 134 | + case '{DAV:}href': |
|
| 135 | + $href = $value; |
|
| 136 | + break; |
|
| 137 | + } |
|
| 138 | + } |
|
| 139 | + if (is_null($calendarUri)) { |
|
| 140 | + throw new BadRequest('The {http://calendarserver.org/ns/}hosturl/{DAV:}href element must exist'); |
|
| 141 | + } |
|
| 142 | 142 | |
| 143 | - return new self($href, $calendarUri, $inReplyTo, $summary, $status); |
|
| 144 | - } |
|
| 143 | + return new self($href, $calendarUri, $inReplyTo, $summary, $status); |
|
| 144 | + } |
|
| 145 | 145 | } |
@@ -23,115 +23,115 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | class CalendarQueryReport implements XmlDeserializable |
| 25 | 25 | { |
| 26 | - /** |
|
| 27 | - * An array with requested properties. |
|
| 28 | - * |
|
| 29 | - * @var array |
|
| 30 | - */ |
|
| 31 | - public $properties; |
|
| 26 | + /** |
|
| 27 | + * An array with requested properties. |
|
| 28 | + * |
|
| 29 | + * @var array |
|
| 30 | + */ |
|
| 31 | + public $properties; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * List of property/component filters. |
|
| 35 | - * |
|
| 36 | - * @var array |
|
| 37 | - */ |
|
| 38 | - public $filters; |
|
| 33 | + /** |
|
| 34 | + * List of property/component filters. |
|
| 35 | + * |
|
| 36 | + * @var array |
|
| 37 | + */ |
|
| 38 | + public $filters; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * If the calendar data must be expanded, this will contain an array with 2 |
|
| 42 | - * elements: start and end. |
|
| 43 | - * |
|
| 44 | - * Each may be a DateTime or null. |
|
| 45 | - * |
|
| 46 | - * @var array|null |
|
| 47 | - */ |
|
| 48 | - public $expand = null; |
|
| 40 | + /** |
|
| 41 | + * If the calendar data must be expanded, this will contain an array with 2 |
|
| 42 | + * elements: start and end. |
|
| 43 | + * |
|
| 44 | + * Each may be a DateTime or null. |
|
| 45 | + * |
|
| 46 | + * @var array|null |
|
| 47 | + */ |
|
| 48 | + public $expand = null; |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * The mimetype of the content that should be returend. Usually |
|
| 52 | - * text/calendar. |
|
| 53 | - * |
|
| 54 | - * @var string |
|
| 55 | - */ |
|
| 56 | - public $contentType = null; |
|
| 50 | + /** |
|
| 51 | + * The mimetype of the content that should be returend. Usually |
|
| 52 | + * text/calendar. |
|
| 53 | + * |
|
| 54 | + * @var string |
|
| 55 | + */ |
|
| 56 | + public $contentType = null; |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * The version of calendar-data that should be returned. Usually '2.0', |
|
| 60 | - * referring to iCalendar 2.0. |
|
| 61 | - * |
|
| 62 | - * @var string |
|
| 63 | - */ |
|
| 64 | - public $version = null; |
|
| 58 | + /** |
|
| 59 | + * The version of calendar-data that should be returned. Usually '2.0', |
|
| 60 | + * referring to iCalendar 2.0. |
|
| 61 | + * |
|
| 62 | + * @var string |
|
| 63 | + */ |
|
| 64 | + public $version = null; |
|
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * The deserialize method is called during xml parsing. |
|
| 68 | - * |
|
| 69 | - * This method is called statically, this is because in theory this method |
|
| 70 | - * may be used as a type of constructor, or factory method. |
|
| 71 | - * |
|
| 72 | - * Often you want to return an instance of the current class, but you are |
|
| 73 | - * free to return other data as well. |
|
| 74 | - * |
|
| 75 | - * You are responsible for advancing the reader to the next element. Not |
|
| 76 | - * doing anything will result in a never-ending loop. |
|
| 77 | - * |
|
| 78 | - * If you just want to skip parsing for this element altogether, you can |
|
| 79 | - * just call $reader->next(); |
|
| 80 | - * |
|
| 81 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
| 82 | - * the next element. |
|
| 83 | - * |
|
| 84 | - * @return mixed |
|
| 85 | - */ |
|
| 86 | - public static function xmlDeserialize(Reader $reader) |
|
| 87 | - { |
|
| 88 | - $elems = $reader->parseInnerTree([ |
|
| 89 | - '{urn:ietf:params:xml:ns:caldav}comp-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\CompFilter', |
|
| 90 | - '{urn:ietf:params:xml:ns:caldav}prop-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\PropFilter', |
|
| 91 | - '{urn:ietf:params:xml:ns:caldav}param-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\ParamFilter', |
|
| 92 | - '{urn:ietf:params:xml:ns:caldav}calendar-data' => 'Sabre\\CalDAV\\Xml\\Filter\\CalendarData', |
|
| 93 | - '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', |
|
| 94 | - ]); |
|
| 66 | + /** |
|
| 67 | + * The deserialize method is called during xml parsing. |
|
| 68 | + * |
|
| 69 | + * This method is called statically, this is because in theory this method |
|
| 70 | + * may be used as a type of constructor, or factory method. |
|
| 71 | + * |
|
| 72 | + * Often you want to return an instance of the current class, but you are |
|
| 73 | + * free to return other data as well. |
|
| 74 | + * |
|
| 75 | + * You are responsible for advancing the reader to the next element. Not |
|
| 76 | + * doing anything will result in a never-ending loop. |
|
| 77 | + * |
|
| 78 | + * If you just want to skip parsing for this element altogether, you can |
|
| 79 | + * just call $reader->next(); |
|
| 80 | + * |
|
| 81 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
| 82 | + * the next element. |
|
| 83 | + * |
|
| 84 | + * @return mixed |
|
| 85 | + */ |
|
| 86 | + public static function xmlDeserialize(Reader $reader) |
|
| 87 | + { |
|
| 88 | + $elems = $reader->parseInnerTree([ |
|
| 89 | + '{urn:ietf:params:xml:ns:caldav}comp-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\CompFilter', |
|
| 90 | + '{urn:ietf:params:xml:ns:caldav}prop-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\PropFilter', |
|
| 91 | + '{urn:ietf:params:xml:ns:caldav}param-filter' => 'Sabre\\CalDAV\\Xml\\Filter\\ParamFilter', |
|
| 92 | + '{urn:ietf:params:xml:ns:caldav}calendar-data' => 'Sabre\\CalDAV\\Xml\\Filter\\CalendarData', |
|
| 93 | + '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', |
|
| 94 | + ]); |
|
| 95 | 95 | |
| 96 | - $newProps = [ |
|
| 97 | - 'filters' => null, |
|
| 98 | - 'properties' => [], |
|
| 99 | - ]; |
|
| 96 | + $newProps = [ |
|
| 97 | + 'filters' => null, |
|
| 98 | + 'properties' => [], |
|
| 99 | + ]; |
|
| 100 | 100 | |
| 101 | - if (!is_array($elems)) { |
|
| 102 | - $elems = []; |
|
| 103 | - } |
|
| 101 | + if (!is_array($elems)) { |
|
| 102 | + $elems = []; |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - foreach ($elems as $elem) { |
|
| 106 | - switch ($elem['name']) { |
|
| 107 | - case '{DAV:}prop': |
|
| 108 | - $newProps['properties'] = array_keys($elem['value']); |
|
| 109 | - if (isset($elem['value']['{'.Plugin::NS_CALDAV.'}calendar-data'])) { |
|
| 110 | - $newProps += $elem['value']['{'.Plugin::NS_CALDAV.'}calendar-data']; |
|
| 111 | - } |
|
| 112 | - break; |
|
| 113 | - case '{'.Plugin::NS_CALDAV.'}filter': |
|
| 114 | - foreach ($elem['value'] as $subElem) { |
|
| 115 | - if ($subElem['name'] === '{'.Plugin::NS_CALDAV.'}comp-filter') { |
|
| 116 | - if (!is_null($newProps['filters'])) { |
|
| 117 | - throw new BadRequest('Only one top-level comp-filter may be defined'); |
|
| 118 | - } |
|
| 119 | - $newProps['filters'] = $subElem['value']; |
|
| 120 | - } |
|
| 121 | - } |
|
| 122 | - break; |
|
| 123 | - } |
|
| 124 | - } |
|
| 105 | + foreach ($elems as $elem) { |
|
| 106 | + switch ($elem['name']) { |
|
| 107 | + case '{DAV:}prop': |
|
| 108 | + $newProps['properties'] = array_keys($elem['value']); |
|
| 109 | + if (isset($elem['value']['{'.Plugin::NS_CALDAV.'}calendar-data'])) { |
|
| 110 | + $newProps += $elem['value']['{'.Plugin::NS_CALDAV.'}calendar-data']; |
|
| 111 | + } |
|
| 112 | + break; |
|
| 113 | + case '{'.Plugin::NS_CALDAV.'}filter': |
|
| 114 | + foreach ($elem['value'] as $subElem) { |
|
| 115 | + if ($subElem['name'] === '{'.Plugin::NS_CALDAV.'}comp-filter') { |
|
| 116 | + if (!is_null($newProps['filters'])) { |
|
| 117 | + throw new BadRequest('Only one top-level comp-filter may be defined'); |
|
| 118 | + } |
|
| 119 | + $newProps['filters'] = $subElem['value']; |
|
| 120 | + } |
|
| 121 | + } |
|
| 122 | + break; |
|
| 123 | + } |
|
| 124 | + } |
|
| 125 | 125 | |
| 126 | - if (is_null($newProps['filters'])) { |
|
| 127 | - throw new BadRequest('The {'.Plugin::NS_CALDAV.'}filter element is required for this request'); |
|
| 128 | - } |
|
| 126 | + if (is_null($newProps['filters'])) { |
|
| 127 | + throw new BadRequest('The {'.Plugin::NS_CALDAV.'}filter element is required for this request'); |
|
| 128 | + } |
|
| 129 | 129 | |
| 130 | - $obj = new self(); |
|
| 131 | - foreach ($newProps as $key => $value) { |
|
| 132 | - $obj->$key = $value; |
|
| 133 | - } |
|
| 130 | + $obj = new self(); |
|
| 131 | + foreach ($newProps as $key => $value) { |
|
| 132 | + $obj->$key = $value; |
|
| 133 | + } |
|
| 134 | 134 | |
| 135 | - return $obj; |
|
| 136 | - } |
|
| 135 | + return $obj; |
|
| 136 | + } |
|
| 137 | 137 | } |
@@ -23,97 +23,97 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | class CalendarMultiGetReport implements XmlDeserializable |
| 25 | 25 | { |
| 26 | - /** |
|
| 27 | - * An array with requested properties. |
|
| 28 | - * |
|
| 29 | - * @var array |
|
| 30 | - */ |
|
| 31 | - public $properties; |
|
| 26 | + /** |
|
| 27 | + * An array with requested properties. |
|
| 28 | + * |
|
| 29 | + * @var array |
|
| 30 | + */ |
|
| 31 | + public $properties; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * This is an array with the urls that are being requested. |
|
| 35 | - * |
|
| 36 | - * @var array |
|
| 37 | - */ |
|
| 38 | - public $hrefs; |
|
| 33 | + /** |
|
| 34 | + * This is an array with the urls that are being requested. |
|
| 35 | + * |
|
| 36 | + * @var array |
|
| 37 | + */ |
|
| 38 | + public $hrefs; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * If the calendar data must be expanded, this will contain an array with 2 |
|
| 42 | - * elements: start and end. |
|
| 43 | - * |
|
| 44 | - * Each may be a DateTime or null. |
|
| 45 | - * |
|
| 46 | - * @var array|null |
|
| 47 | - */ |
|
| 48 | - public $expand = null; |
|
| 40 | + /** |
|
| 41 | + * If the calendar data must be expanded, this will contain an array with 2 |
|
| 42 | + * elements: start and end. |
|
| 43 | + * |
|
| 44 | + * Each may be a DateTime or null. |
|
| 45 | + * |
|
| 46 | + * @var array|null |
|
| 47 | + */ |
|
| 48 | + public $expand = null; |
|
| 49 | 49 | |
| 50 | - /** |
|
| 51 | - * The mimetype of the content that should be returend. Usually |
|
| 52 | - * text/calendar. |
|
| 53 | - * |
|
| 54 | - * @var string |
|
| 55 | - */ |
|
| 56 | - public $contentType = null; |
|
| 50 | + /** |
|
| 51 | + * The mimetype of the content that should be returend. Usually |
|
| 52 | + * text/calendar. |
|
| 53 | + * |
|
| 54 | + * @var string |
|
| 55 | + */ |
|
| 56 | + public $contentType = null; |
|
| 57 | 57 | |
| 58 | - /** |
|
| 59 | - * The version of calendar-data that should be returned. Usually '2.0', |
|
| 60 | - * referring to iCalendar 2.0. |
|
| 61 | - * |
|
| 62 | - * @var string |
|
| 63 | - */ |
|
| 64 | - public $version = null; |
|
| 58 | + /** |
|
| 59 | + * The version of calendar-data that should be returned. Usually '2.0', |
|
| 60 | + * referring to iCalendar 2.0. |
|
| 61 | + * |
|
| 62 | + * @var string |
|
| 63 | + */ |
|
| 64 | + public $version = null; |
|
| 65 | 65 | |
| 66 | - /** |
|
| 67 | - * The deserialize method is called during xml parsing. |
|
| 68 | - * |
|
| 69 | - * This method is called statically, this is because in theory this method |
|
| 70 | - * may be used as a type of constructor, or factory method. |
|
| 71 | - * |
|
| 72 | - * Often you want to return an instance of the current class, but you are |
|
| 73 | - * free to return other data as well. |
|
| 74 | - * |
|
| 75 | - * You are responsible for advancing the reader to the next element. Not |
|
| 76 | - * doing anything will result in a never-ending loop. |
|
| 77 | - * |
|
| 78 | - * If you just want to skip parsing for this element altogether, you can |
|
| 79 | - * just call $reader->next(); |
|
| 80 | - * |
|
| 81 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
| 82 | - * the next element. |
|
| 83 | - * |
|
| 84 | - * @return mixed |
|
| 85 | - */ |
|
| 86 | - public static function xmlDeserialize(Reader $reader) |
|
| 87 | - { |
|
| 88 | - $elems = $reader->parseInnerTree([ |
|
| 89 | - '{urn:ietf:params:xml:ns:caldav}calendar-data' => 'Sabre\\CalDAV\\Xml\\Filter\\CalendarData', |
|
| 90 | - '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', |
|
| 91 | - ]); |
|
| 66 | + /** |
|
| 67 | + * The deserialize method is called during xml parsing. |
|
| 68 | + * |
|
| 69 | + * This method is called statically, this is because in theory this method |
|
| 70 | + * may be used as a type of constructor, or factory method. |
|
| 71 | + * |
|
| 72 | + * Often you want to return an instance of the current class, but you are |
|
| 73 | + * free to return other data as well. |
|
| 74 | + * |
|
| 75 | + * You are responsible for advancing the reader to the next element. Not |
|
| 76 | + * doing anything will result in a never-ending loop. |
|
| 77 | + * |
|
| 78 | + * If you just want to skip parsing for this element altogether, you can |
|
| 79 | + * just call $reader->next(); |
|
| 80 | + * |
|
| 81 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
| 82 | + * the next element. |
|
| 83 | + * |
|
| 84 | + * @return mixed |
|
| 85 | + */ |
|
| 86 | + public static function xmlDeserialize(Reader $reader) |
|
| 87 | + { |
|
| 88 | + $elems = $reader->parseInnerTree([ |
|
| 89 | + '{urn:ietf:params:xml:ns:caldav}calendar-data' => 'Sabre\\CalDAV\\Xml\\Filter\\CalendarData', |
|
| 90 | + '{DAV:}prop' => 'Sabre\\Xml\\Element\\KeyValue', |
|
| 91 | + ]); |
|
| 92 | 92 | |
| 93 | - $newProps = [ |
|
| 94 | - 'hrefs' => [], |
|
| 95 | - 'properties' => [], |
|
| 96 | - ]; |
|
| 93 | + $newProps = [ |
|
| 94 | + 'hrefs' => [], |
|
| 95 | + 'properties' => [], |
|
| 96 | + ]; |
|
| 97 | 97 | |
| 98 | - foreach ($elems as $elem) { |
|
| 99 | - switch ($elem['name']) { |
|
| 100 | - case '{DAV:}prop': |
|
| 101 | - $newProps['properties'] = array_keys($elem['value']); |
|
| 102 | - if (isset($elem['value']['{'.Plugin::NS_CALDAV.'}calendar-data'])) { |
|
| 103 | - $newProps += $elem['value']['{'.Plugin::NS_CALDAV.'}calendar-data']; |
|
| 104 | - } |
|
| 105 | - break; |
|
| 106 | - case '{DAV:}href': |
|
| 107 | - $newProps['hrefs'][] = Uri\resolve($reader->contextUri, $elem['value']); |
|
| 108 | - break; |
|
| 109 | - } |
|
| 110 | - } |
|
| 98 | + foreach ($elems as $elem) { |
|
| 99 | + switch ($elem['name']) { |
|
| 100 | + case '{DAV:}prop': |
|
| 101 | + $newProps['properties'] = array_keys($elem['value']); |
|
| 102 | + if (isset($elem['value']['{'.Plugin::NS_CALDAV.'}calendar-data'])) { |
|
| 103 | + $newProps += $elem['value']['{'.Plugin::NS_CALDAV.'}calendar-data']; |
|
| 104 | + } |
|
| 105 | + break; |
|
| 106 | + case '{DAV:}href': |
|
| 107 | + $newProps['hrefs'][] = Uri\resolve($reader->contextUri, $elem['value']); |
|
| 108 | + break; |
|
| 109 | + } |
|
| 110 | + } |
|
| 111 | 111 | |
| 112 | - $obj = new self(); |
|
| 113 | - foreach ($newProps as $key => $value) { |
|
| 114 | - $obj->$key = $value; |
|
| 115 | - } |
|
| 112 | + $obj = new self(); |
|
| 113 | + foreach ($newProps as $key => $value) { |
|
| 114 | + $obj->$key = $value; |
|
| 115 | + } |
|
| 116 | 116 | |
| 117 | - return $obj; |
|
| 118 | - } |
|
| 117 | + return $obj; |
|
| 118 | + } |
|
| 119 | 119 | } |
@@ -23,68 +23,68 @@ |
||
| 23 | 23 | */ |
| 24 | 24 | class FreeBusyQueryReport implements XmlDeserializable |
| 25 | 25 | { |
| 26 | - /** |
|
| 27 | - * Starttime of report. |
|
| 28 | - * |
|
| 29 | - * @var \DateTime|null |
|
| 30 | - */ |
|
| 31 | - public $start; |
|
| 26 | + /** |
|
| 27 | + * Starttime of report. |
|
| 28 | + * |
|
| 29 | + * @var \DateTime|null |
|
| 30 | + */ |
|
| 31 | + public $start; |
|
| 32 | 32 | |
| 33 | - /** |
|
| 34 | - * End time of report. |
|
| 35 | - * |
|
| 36 | - * @var \DateTime|null |
|
| 37 | - */ |
|
| 38 | - public $end; |
|
| 33 | + /** |
|
| 34 | + * End time of report. |
|
| 35 | + * |
|
| 36 | + * @var \DateTime|null |
|
| 37 | + */ |
|
| 38 | + public $end; |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * The deserialize method is called during xml parsing. |
|
| 42 | - * |
|
| 43 | - * This method is called statically, this is because in theory this method |
|
| 44 | - * may be used as a type of constructor, or factory method. |
|
| 45 | - * |
|
| 46 | - * Often you want to return an instance of the current class, but you are |
|
| 47 | - * free to return other data as well. |
|
| 48 | - * |
|
| 49 | - * You are responsible for advancing the reader to the next element. Not |
|
| 50 | - * doing anything will result in a never-ending loop. |
|
| 51 | - * |
|
| 52 | - * If you just want to skip parsing for this element altogether, you can |
|
| 53 | - * just call $reader->next(); |
|
| 54 | - * |
|
| 55 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
| 56 | - * the next element. |
|
| 57 | - * |
|
| 58 | - * @return mixed |
|
| 59 | - */ |
|
| 60 | - public static function xmlDeserialize(Reader $reader) |
|
| 61 | - { |
|
| 62 | - $timeRange = '{'.Plugin::NS_CALDAV.'}time-range'; |
|
| 40 | + /** |
|
| 41 | + * The deserialize method is called during xml parsing. |
|
| 42 | + * |
|
| 43 | + * This method is called statically, this is because in theory this method |
|
| 44 | + * may be used as a type of constructor, or factory method. |
|
| 45 | + * |
|
| 46 | + * Often you want to return an instance of the current class, but you are |
|
| 47 | + * free to return other data as well. |
|
| 48 | + * |
|
| 49 | + * You are responsible for advancing the reader to the next element. Not |
|
| 50 | + * doing anything will result in a never-ending loop. |
|
| 51 | + * |
|
| 52 | + * If you just want to skip parsing for this element altogether, you can |
|
| 53 | + * just call $reader->next(); |
|
| 54 | + * |
|
| 55 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
| 56 | + * the next element. |
|
| 57 | + * |
|
| 58 | + * @return mixed |
|
| 59 | + */ |
|
| 60 | + public static function xmlDeserialize(Reader $reader) |
|
| 61 | + { |
|
| 62 | + $timeRange = '{'.Plugin::NS_CALDAV.'}time-range'; |
|
| 63 | 63 | |
| 64 | - $start = null; |
|
| 65 | - $end = null; |
|
| 64 | + $start = null; |
|
| 65 | + $end = null; |
|
| 66 | 66 | |
| 67 | - foreach ((array) $reader->parseInnerTree([]) as $elem) { |
|
| 68 | - if ($elem['name'] !== $timeRange) { |
|
| 69 | - continue; |
|
| 70 | - } |
|
| 67 | + foreach ((array) $reader->parseInnerTree([]) as $elem) { |
|
| 68 | + if ($elem['name'] !== $timeRange) { |
|
| 69 | + continue; |
|
| 70 | + } |
|
| 71 | 71 | |
| 72 | - $start = empty($elem['attributes']['start']) ?: $elem['attributes']['start']; |
|
| 73 | - $end = empty($elem['attributes']['end']) ?: $elem['attributes']['end']; |
|
| 74 | - } |
|
| 75 | - if (!$start && !$end) { |
|
| 76 | - throw new BadRequest('The freebusy report must have a time-range element'); |
|
| 77 | - } |
|
| 78 | - if ($start) { |
|
| 79 | - $start = DateTimeParser::parseDateTime($start); |
|
| 80 | - } |
|
| 81 | - if ($end) { |
|
| 82 | - $end = DateTimeParser::parseDateTime($end); |
|
| 83 | - } |
|
| 84 | - $result = new self(); |
|
| 85 | - $result->start = $start; |
|
| 86 | - $result->end = $end; |
|
| 72 | + $start = empty($elem['attributes']['start']) ?: $elem['attributes']['start']; |
|
| 73 | + $end = empty($elem['attributes']['end']) ?: $elem['attributes']['end']; |
|
| 74 | + } |
|
| 75 | + if (!$start && !$end) { |
|
| 76 | + throw new BadRequest('The freebusy report must have a time-range element'); |
|
| 77 | + } |
|
| 78 | + if ($start) { |
|
| 79 | + $start = DateTimeParser::parseDateTime($start); |
|
| 80 | + } |
|
| 81 | + if ($end) { |
|
| 82 | + $end = DateTimeParser::parseDateTime($end); |
|
| 83 | + } |
|
| 84 | + $result = new self(); |
|
| 85 | + $result->start = $start; |
|
| 86 | + $result->end = $end; |
|
| 87 | 87 | |
| 88 | - return $result; |
|
| 89 | - } |
|
| 88 | + return $result; |
|
| 89 | + } |
|
| 90 | 90 | } |
@@ -22,86 +22,86 @@ |
||
| 22 | 22 | */ |
| 23 | 23 | class Share implements XmlDeserializable |
| 24 | 24 | { |
| 25 | - /** |
|
| 26 | - * The list of new people added or updated or removed from the share. |
|
| 27 | - * |
|
| 28 | - * @var Sharee[] |
|
| 29 | - */ |
|
| 30 | - public $sharees = []; |
|
| 25 | + /** |
|
| 26 | + * The list of new people added or updated or removed from the share. |
|
| 27 | + * |
|
| 28 | + * @var Sharee[] |
|
| 29 | + */ |
|
| 30 | + public $sharees = []; |
|
| 31 | 31 | |
| 32 | - /** |
|
| 33 | - * Constructor. |
|
| 34 | - * |
|
| 35 | - * @param Sharee[] $sharees |
|
| 36 | - */ |
|
| 37 | - public function __construct(array $sharees) |
|
| 38 | - { |
|
| 39 | - $this->sharees = $sharees; |
|
| 40 | - } |
|
| 32 | + /** |
|
| 33 | + * Constructor. |
|
| 34 | + * |
|
| 35 | + * @param Sharee[] $sharees |
|
| 36 | + */ |
|
| 37 | + public function __construct(array $sharees) |
|
| 38 | + { |
|
| 39 | + $this->sharees = $sharees; |
|
| 40 | + } |
|
| 41 | 41 | |
| 42 | - /** |
|
| 43 | - * The deserialize method is called during xml parsing. |
|
| 44 | - * |
|
| 45 | - * This method is called statically, this is because in theory this method |
|
| 46 | - * may be used as a type of constructor, or factory method. |
|
| 47 | - * |
|
| 48 | - * Often you want to return an instance of the current class, but you are |
|
| 49 | - * free to return other data as well. |
|
| 50 | - * |
|
| 51 | - * You are responsible for advancing the reader to the next element. Not |
|
| 52 | - * doing anything will result in a never-ending loop. |
|
| 53 | - * |
|
| 54 | - * If you just want to skip parsing for this element altogether, you can |
|
| 55 | - * just call $reader->next(); |
|
| 56 | - * |
|
| 57 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
| 58 | - * the next element. |
|
| 59 | - * |
|
| 60 | - * @return mixed |
|
| 61 | - */ |
|
| 62 | - public static function xmlDeserialize(Reader $reader) |
|
| 63 | - { |
|
| 64 | - $elems = $reader->parseGetElements([ |
|
| 65 | - '{'.Plugin::NS_CALENDARSERVER.'}set' => 'Sabre\\Xml\\Element\\KeyValue', |
|
| 66 | - '{'.Plugin::NS_CALENDARSERVER.'}remove' => 'Sabre\\Xml\\Element\\KeyValue', |
|
| 67 | - ]); |
|
| 42 | + /** |
|
| 43 | + * The deserialize method is called during xml parsing. |
|
| 44 | + * |
|
| 45 | + * This method is called statically, this is because in theory this method |
|
| 46 | + * may be used as a type of constructor, or factory method. |
|
| 47 | + * |
|
| 48 | + * Often you want to return an instance of the current class, but you are |
|
| 49 | + * free to return other data as well. |
|
| 50 | + * |
|
| 51 | + * You are responsible for advancing the reader to the next element. Not |
|
| 52 | + * doing anything will result in a never-ending loop. |
|
| 53 | + * |
|
| 54 | + * If you just want to skip parsing for this element altogether, you can |
|
| 55 | + * just call $reader->next(); |
|
| 56 | + * |
|
| 57 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
| 58 | + * the next element. |
|
| 59 | + * |
|
| 60 | + * @return mixed |
|
| 61 | + */ |
|
| 62 | + public static function xmlDeserialize(Reader $reader) |
|
| 63 | + { |
|
| 64 | + $elems = $reader->parseGetElements([ |
|
| 65 | + '{'.Plugin::NS_CALENDARSERVER.'}set' => 'Sabre\\Xml\\Element\\KeyValue', |
|
| 66 | + '{'.Plugin::NS_CALENDARSERVER.'}remove' => 'Sabre\\Xml\\Element\\KeyValue', |
|
| 67 | + ]); |
|
| 68 | 68 | |
| 69 | - $sharees = []; |
|
| 69 | + $sharees = []; |
|
| 70 | 70 | |
| 71 | - foreach ($elems as $elem) { |
|
| 72 | - switch ($elem['name']) { |
|
| 73 | - case '{'.Plugin::NS_CALENDARSERVER.'}set': |
|
| 74 | - $sharee = $elem['value']; |
|
| 71 | + foreach ($elems as $elem) { |
|
| 72 | + switch ($elem['name']) { |
|
| 73 | + case '{'.Plugin::NS_CALENDARSERVER.'}set': |
|
| 74 | + $sharee = $elem['value']; |
|
| 75 | 75 | |
| 76 | - $sumElem = '{'.Plugin::NS_CALENDARSERVER.'}summary'; |
|
| 77 | - $commonName = '{'.Plugin::NS_CALENDARSERVER.'}common-name'; |
|
| 76 | + $sumElem = '{'.Plugin::NS_CALENDARSERVER.'}summary'; |
|
| 77 | + $commonName = '{'.Plugin::NS_CALENDARSERVER.'}common-name'; |
|
| 78 | 78 | |
| 79 | - $properties = []; |
|
| 80 | - if (isset($sharee[$commonName])) { |
|
| 81 | - $properties['{DAV:}displayname'] = $sharee[$commonName]; |
|
| 82 | - } |
|
| 79 | + $properties = []; |
|
| 80 | + if (isset($sharee[$commonName])) { |
|
| 81 | + $properties['{DAV:}displayname'] = $sharee[$commonName]; |
|
| 82 | + } |
|
| 83 | 83 | |
| 84 | - $access = array_key_exists('{'.Plugin::NS_CALENDARSERVER.'}read-write', $sharee) |
|
| 85 | - ? \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE |
|
| 86 | - : \Sabre\DAV\Sharing\Plugin::ACCESS_READ; |
|
| 84 | + $access = array_key_exists('{'.Plugin::NS_CALENDARSERVER.'}read-write', $sharee) |
|
| 85 | + ? \Sabre\DAV\Sharing\Plugin::ACCESS_READWRITE |
|
| 86 | + : \Sabre\DAV\Sharing\Plugin::ACCESS_READ; |
|
| 87 | 87 | |
| 88 | - $sharees[] = new Sharee([ |
|
| 89 | - 'href' => $sharee['{DAV:}href'], |
|
| 90 | - 'properties' => $properties, |
|
| 91 | - 'access' => $access, |
|
| 92 | - 'comment' => isset($sharee[$sumElem]) ? $sharee[$sumElem] : null, |
|
| 93 | - ]); |
|
| 94 | - break; |
|
| 88 | + $sharees[] = new Sharee([ |
|
| 89 | + 'href' => $sharee['{DAV:}href'], |
|
| 90 | + 'properties' => $properties, |
|
| 91 | + 'access' => $access, |
|
| 92 | + 'comment' => isset($sharee[$sumElem]) ? $sharee[$sumElem] : null, |
|
| 93 | + ]); |
|
| 94 | + break; |
|
| 95 | 95 | |
| 96 | - case '{'.Plugin::NS_CALENDARSERVER.'}remove': |
|
| 97 | - $sharees[] = new Sharee([ |
|
| 98 | - 'href' => $elem['value']['{DAV:}href'], |
|
| 99 | - 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_NOACCESS, |
|
| 100 | - ]); |
|
| 101 | - break; |
|
| 102 | - } |
|
| 103 | - } |
|
| 96 | + case '{'.Plugin::NS_CALENDARSERVER.'}remove': |
|
| 97 | + $sharees[] = new Sharee([ |
|
| 98 | + 'href' => $elem['value']['{DAV:}href'], |
|
| 99 | + 'access' => \Sabre\DAV\Sharing\Plugin::ACCESS_NOACCESS, |
|
| 100 | + ]); |
|
| 101 | + break; |
|
| 102 | + } |
|
| 103 | + } |
|
| 104 | 104 | |
| 105 | - return new self($sharees); |
|
| 106 | - } |
|
| 105 | + return new self($sharees); |
|
| 106 | + } |
|
| 107 | 107 | } |
@@ -20,58 +20,58 @@ |
||
| 20 | 20 | */ |
| 21 | 21 | class MkCalendar implements XmlDeserializable |
| 22 | 22 | { |
| 23 | - /** |
|
| 24 | - * The list of properties that will be set. |
|
| 25 | - * |
|
| 26 | - * @var array |
|
| 27 | - */ |
|
| 28 | - public $properties = []; |
|
| 23 | + /** |
|
| 24 | + * The list of properties that will be set. |
|
| 25 | + * |
|
| 26 | + * @var array |
|
| 27 | + */ |
|
| 28 | + public $properties = []; |
|
| 29 | 29 | |
| 30 | - /** |
|
| 31 | - * Returns the list of properties the calendar will be initialized with. |
|
| 32 | - * |
|
| 33 | - * @return array |
|
| 34 | - */ |
|
| 35 | - public function getProperties() |
|
| 36 | - { |
|
| 37 | - return $this->properties; |
|
| 38 | - } |
|
| 30 | + /** |
|
| 31 | + * Returns the list of properties the calendar will be initialized with. |
|
| 32 | + * |
|
| 33 | + * @return array |
|
| 34 | + */ |
|
| 35 | + public function getProperties() |
|
| 36 | + { |
|
| 37 | + return $this->properties; |
|
| 38 | + } |
|
| 39 | 39 | |
| 40 | - /** |
|
| 41 | - * The deserialize method is called during xml parsing. |
|
| 42 | - * |
|
| 43 | - * This method is called statically, this is because in theory this method |
|
| 44 | - * may be used as a type of constructor, or factory method. |
|
| 45 | - * |
|
| 46 | - * Often you want to return an instance of the current class, but you are |
|
| 47 | - * free to return other data as well. |
|
| 48 | - * |
|
| 49 | - * You are responsible for advancing the reader to the next element. Not |
|
| 50 | - * doing anything will result in a never-ending loop. |
|
| 51 | - * |
|
| 52 | - * If you just want to skip parsing for this element altogether, you can |
|
| 53 | - * just call $reader->next(); |
|
| 54 | - * |
|
| 55 | - * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
| 56 | - * the next element. |
|
| 57 | - * |
|
| 58 | - * @return mixed |
|
| 59 | - */ |
|
| 60 | - public static function xmlDeserialize(Reader $reader) |
|
| 61 | - { |
|
| 62 | - $self = new self(); |
|
| 40 | + /** |
|
| 41 | + * The deserialize method is called during xml parsing. |
|
| 42 | + * |
|
| 43 | + * This method is called statically, this is because in theory this method |
|
| 44 | + * may be used as a type of constructor, or factory method. |
|
| 45 | + * |
|
| 46 | + * Often you want to return an instance of the current class, but you are |
|
| 47 | + * free to return other data as well. |
|
| 48 | + * |
|
| 49 | + * You are responsible for advancing the reader to the next element. Not |
|
| 50 | + * doing anything will result in a never-ending loop. |
|
| 51 | + * |
|
| 52 | + * If you just want to skip parsing for this element altogether, you can |
|
| 53 | + * just call $reader->next(); |
|
| 54 | + * |
|
| 55 | + * $reader->parseInnerTree() will parse the entire sub-tree, and advance to |
|
| 56 | + * the next element. |
|
| 57 | + * |
|
| 58 | + * @return mixed |
|
| 59 | + */ |
|
| 60 | + public static function xmlDeserialize(Reader $reader) |
|
| 61 | + { |
|
| 62 | + $self = new self(); |
|
| 63 | 63 | |
| 64 | - $elementMap = $reader->elementMap; |
|
| 65 | - $elementMap['{DAV:}prop'] = 'Sabre\DAV\Xml\Element\Prop'; |
|
| 66 | - $elementMap['{DAV:}set'] = 'Sabre\Xml\Element\KeyValue'; |
|
| 67 | - $elems = $reader->parseInnerTree($elementMap); |
|
| 64 | + $elementMap = $reader->elementMap; |
|
| 65 | + $elementMap['{DAV:}prop'] = 'Sabre\DAV\Xml\Element\Prop'; |
|
| 66 | + $elementMap['{DAV:}set'] = 'Sabre\Xml\Element\KeyValue'; |
|
| 67 | + $elems = $reader->parseInnerTree($elementMap); |
|
| 68 | 68 | |
| 69 | - foreach ($elems as $elem) { |
|
| 70 | - if ('{DAV:}set' === $elem['name']) { |
|
| 71 | - $self->properties = array_merge($self->properties, $elem['value']['{DAV:}prop']); |
|
| 72 | - } |
|
| 73 | - } |
|
| 69 | + foreach ($elems as $elem) { |
|
| 70 | + if ('{DAV:}set' === $elem['name']) { |
|
| 71 | + $self->properties = array_merge($self->properties, $elem['value']['{DAV:}prop']); |
|
| 72 | + } |
|
| 73 | + } |
|
| 74 | 74 | |
| 75 | - return $self; |
|
| 76 | - } |
|
| 75 | + return $self; |
|
| 76 | + } |
|
| 77 | 77 | } |