Skip to content

Commit

Permalink
[smarcet]
Browse files Browse the repository at this point in the history
* fixed calendar time range query
  • Loading branch information
smarcet committed May 3, 2018
1 parent 1f9fcca commit 08d1d94
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 6 deletions.
13 changes: 8 additions & 5 deletions src/Facade/Requests/CalendarQueryFilter.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,15 +43,18 @@ final class CalendarQueryFilter
* CalendarQueryFilter constructor.
* @param bool $get_etags
* @param bool $get_calendar_data
* @param DateTime $to
* @param DateTime $from
* @param DateTime $to
*/
public function __construct($get_etags = true, $get_calendar_data = false, DateTime $to = null, DateTime $from = null)
public function __construct($get_etags = true, $get_calendar_data = false, DateTime $from = null, DateTime $to = null)
{
$this->get_etags = $get_etags;
$this->get_etags = $get_etags;
$this->get_calendar_data = $get_calendar_data;
$this->to = $to;
$this->from = $from;
$this->from = $from;
$this->to = $to;

if(!is_null($this->from) && !is_null($this->to) && $this->from > $this->to)
throw new \InvalidArgumentException("from should be lower than to param");
}

/**
Expand Down
5 changes: 5 additions & 0 deletions src/Facade/Responses/GetCalendarResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,18 @@
*/
final class GetCalendarResponse extends ETagEntityResponse
{
const ResourceTypeCalendar = 'calendar';
/**
* @return string
*/
public function getDisplayName(){
return isset($this->found_props['displayname']) ? $this->found_props['displayname'] : null;
}

public function getResourceType(){
return isset($this->found_props['resourcetype']) ? $this->found_props['resourcetype'] : null;
}

/**
* @see https://tools.ietf.org/html/rfc6578
* @return string
Expand Down
14 changes: 13 additions & 1 deletion src/Facade/Responses/GetCalendarsResponse.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,25 @@
*/
final class GetCalendarsResponse extends GenericMultiCalDAVResponse
{

/**
* @return GenericSinglePROPFINDCalDAVResponse
*/
protected function buildSingleResponse()
{
return new GetCalendarResponse();
}

/**
* @param string $type
* @return array
*/
public function getResponseByType($type){
$responses = [];
foreach ($this->getResponses() as $response){
$resource_types = $response->getResourceType();
if(in_array($type, array_keys($resource_types))) $responses[] = $response;
}
return $responses;
}
}

0 comments on commit 08d1d94

Please sign in to comment.