Skip to content

Commit 08d1d94

Browse files
committed
[smarcet]
* fixed calendar time range query
1 parent 1f9fcca commit 08d1d94

File tree

3 files changed

+26
-6
lines changed

3 files changed

+26
-6
lines changed

src/Facade/Requests/CalendarQueryFilter.php

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -43,15 +43,18 @@ final class CalendarQueryFilter
4343
* CalendarQueryFilter constructor.
4444
* @param bool $get_etags
4545
* @param bool $get_calendar_data
46-
* @param DateTime $to
4746
* @param DateTime $from
47+
* @param DateTime $to
4848
*/
49-
public function __construct($get_etags = true, $get_calendar_data = false, DateTime $to = null, DateTime $from = null)
49+
public function __construct($get_etags = true, $get_calendar_data = false, DateTime $from = null, DateTime $to = null)
5050
{
51-
$this->get_etags = $get_etags;
51+
$this->get_etags = $get_etags;
5252
$this->get_calendar_data = $get_calendar_data;
53-
$this->to = $to;
54-
$this->from = $from;
53+
$this->from = $from;
54+
$this->to = $to;
55+
56+
if(!is_null($this->from) && !is_null($this->to) && $this->from > $this->to)
57+
throw new \InvalidArgumentException("from should be lower than to param");
5558
}
5659

5760
/**

src/Facade/Responses/GetCalendarResponse.php

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,13 +18,18 @@
1818
*/
1919
final class GetCalendarResponse extends ETagEntityResponse
2020
{
21+
const ResourceTypeCalendar = 'calendar';
2122
/**
2223
* @return string
2324
*/
2425
public function getDisplayName(){
2526
return isset($this->found_props['displayname']) ? $this->found_props['displayname'] : null;
2627
}
2728

29+
public function getResourceType(){
30+
return isset($this->found_props['resourcetype']) ? $this->found_props['resourcetype'] : null;
31+
}
32+
2833
/**
2934
* @see https://tools.ietf.org/html/rfc6578
3035
* @return string

src/Facade/Responses/GetCalendarsResponse.php

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,13 +20,25 @@
2020
*/
2121
final class GetCalendarsResponse extends GenericMultiCalDAVResponse
2222
{
23-
2423
/**
2524
* @return GenericSinglePROPFINDCalDAVResponse
2625
*/
2726
protected function buildSingleResponse()
2827
{
2928
return new GetCalendarResponse();
3029
}
30+
31+
/**
32+
* @param string $type
33+
* @return array
34+
*/
35+
public function getResponseByType($type){
36+
$responses = [];
37+
foreach ($this->getResponses() as $response){
38+
$resource_types = $response->getResourceType();
39+
if(in_array($type, array_keys($resource_types))) $responses[] = $response;
40+
}
41+
return $responses;
42+
}
3143
}
3244

0 commit comments

Comments
 (0)