1
|
|
|
<?php namespace CalDAVClient\Facade\Responses; |
2
|
|
|
/** |
3
|
|
|
* Copyright 2017 OpenStack Foundation |
4
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
5
|
|
|
* you may not use this file except in compliance with the License. |
6
|
|
|
* You may obtain a copy of the License at |
7
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0 |
8
|
|
|
* Unless required by applicable law or agreed to in writing, software |
9
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, |
10
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
11
|
|
|
* See the License for the specific language governing permissions and |
12
|
|
|
* limitations under the License. |
13
|
|
|
**/ |
14
|
|
|
|
15
|
|
|
/** |
16
|
|
|
* Class GenericMultiCalDAVResponse |
17
|
|
|
* @package CalDAVClient\Facade\Responses |
18
|
|
|
*/ |
19
|
|
|
class GenericMultiCalDAVResponse extends AbstractCalDAVResponse |
20
|
|
|
{ |
21
|
|
|
/** |
22
|
|
|
* @var GenericSinglePROPFINDCalDAVResponse[] |
23
|
|
|
*/ |
24
|
|
|
protected $responses = []; |
25
|
|
|
|
26
|
|
|
protected function parse() |
27
|
|
|
{ |
28
|
|
|
if(isset($this->content['response'])){ |
29
|
|
|
|
30
|
|
|
if(isset($this->content['response']['propstat'])) { |
31
|
|
|
// its a collection with one single element |
32
|
|
|
$single_resource = $this->buildSingleResponse(); |
33
|
|
|
$single_resource->setContent(['response' => $this->content['response']]); |
34
|
|
|
$single_resource->parse(); |
35
|
|
|
$this->responses[] = $single_resource; |
36
|
|
|
return; |
37
|
|
|
} |
38
|
|
|
|
39
|
|
|
foreach ($this->content['response'] as $val) { |
40
|
|
|
$single_resource = $this->buildSingleResponse(); |
41
|
|
|
$single_resource->setContent(['response' => $val]); |
42
|
|
|
$single_resource->parse(); |
43
|
|
|
$this->responses[] = $single_resource; |
44
|
|
|
} |
45
|
|
|
} |
46
|
|
|
} |
47
|
|
|
|
48
|
|
|
/** |
49
|
|
|
* @return GenericSinglePROPFINDCalDAVResponse[] |
50
|
|
|
*/ |
51
|
|
|
public function getResponses(){ |
52
|
|
|
return $this->responses; |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
/** |
56
|
|
|
* @return GenericSinglePROPFINDCalDAVResponse |
57
|
|
|
*/ |
58
|
|
|
protected function buildSingleResponse() |
59
|
|
|
{ |
60
|
|
|
return new GenericSinglePROPFINDCalDAVResponse(); |
61
|
|
|
} |
62
|
|
|
|
63
|
|
|
/** |
64
|
|
|
* @return bool |
65
|
|
|
*/ |
66
|
|
|
public function isSuccessFull() |
67
|
|
|
{ |
68
|
|
|
return $this->code == HttpResponse::HttpCodeMultiResponse; |
69
|
|
|
} |
70
|
|
|
} |