ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sabre\CalDAV\Backend\MockSubscriptionSupport Class Reference

This is a mock CalDAV backend that supports subscriptions. More...

+ Inheritance diagram for Sabre\CalDAV\Backend\MockSubscriptionSupport:
+ Collaboration diagram for Sabre\CalDAV\Backend\MockSubscriptionSupport:

Public Member Functions

 getSubscriptionsForUser ($principalUri)
 Returns a list of subscriptions for a principal. More...
 
 createSubscription ($principalUri, $uri, array $properties)
 Creates a new subscription for a principal. More...
 
 updateSubscription ($subscriptionId, DAV\PropPatch $propPatch)
 Updates a subscription. More...
 
 deleteSubscription ($subscriptionId)
 Deletes a subscription. More...
 
- Public Member Functions inherited from Sabre\CalDAV\Backend\Mock
 __construct (array $calendars=[], array $calendarData=[])
 
 getCalendarsForUser ($principalUri)
 Returns a list of calendars for a principal. More...
 
 createCalendar ($principalUri, $calendarUri, array $properties)
 Creates a new calendar for a principal. More...
 
 updateCalendar ($calendarId, \Sabre\DAV\PropPatch $propPatch)
 Updates properties for a calendar. More...
 
 deleteCalendar ($calendarId)
 Delete a calendar and all it's objects. More...
 
 getCalendarObjects ($calendarId)
 Returns all calendar objects within a calendar object. More...
 
 getCalendarObject ($calendarId, $objectUri)
 Returns information from a single calendar object, based on it's object uri. More...
 
 createCalendarObject ($calendarId, $objectUri, $calendarData)
 Creates a new calendar object. More...
 
 updateCalendarObject ($calendarId, $objectUri, $calendarData)
 Updates an existing calendarobject, based on it's uri. More...
 
 deleteCalendarObject ($calendarId, $objectUri)
 Deletes an existing calendar object. More...
 
- Public Member Functions inherited from Sabre\CalDAV\Backend\AbstractBackend
 updateCalendar ($calendarId, \Sabre\DAV\PropPatch $propPatch)
 Updates properties for a calendar. More...
 
 getMultipleCalendarObjects ($calendarId, array $uris)
 Returns a list of calendar objects. More...
 
 calendarQuery ($calendarId, array $filters)
 Performs a calendar-query on the contents of this calendar. More...
 
 getCalendarObjectByUID ($principalUri, $uid)
 Searches through all of a users calendars and calendar objects to find an object with a specific UID. More...
 
 getCalendarsForUser ($principalUri)
 Returns a list of calendars for a principal. More...
 
 createCalendar ($principalUri, $calendarUri, array $properties)
 Creates a new calendar for a principal. More...
 
 updateCalendar ($calendarId, \Sabre\DAV\PropPatch $propPatch)
 Updates properties for a calendar. More...
 
 deleteCalendar ($calendarId)
 Delete a calendar and all its objects. More...
 
 getCalendarObjects ($calendarId)
 Returns all calendar objects within a calendar. More...
 
 getCalendarObject ($calendarId, $objectUri)
 Returns information from a single calendar object, based on it's object uri. More...
 
 getMultipleCalendarObjects ($calendarId, array $uris)
 Returns a list of calendar objects. More...
 
 createCalendarObject ($calendarId, $objectUri, $calendarData)
 Creates a new calendar object. More...
 
 updateCalendarObject ($calendarId, $objectUri, $calendarData)
 Updates an existing calendarobject, based on it's uri. More...
 
 deleteCalendarObject ($calendarId, $objectUri)
 Deletes an existing calendar object. More...
 
 calendarQuery ($calendarId, array $filters)
 Performs a calendar-query on the contents of this calendar. More...
 
 getCalendarObjectByUID ($principalUri, $uid)
 Searches through all of a users calendars and calendar objects to find an object with a specific UID. More...
 
 getSubscriptionsForUser ($principalUri)
 Returns a list of subscriptions for a principal. More...
 
 createSubscription ($principalUri, $uri, array $properties)
 Creates a new subscription for a principal. More...
 
 updateSubscription ($subscriptionId, DAV\PropPatch $propPatch)
 Updates a subscription. More...
 
 deleteSubscription ($subscriptionId)
 Deletes a subscription. More...
 

Protected Attributes

 $subs = []
 
- Protected Attributes inherited from Sabre\CalDAV\Backend\Mock
 $calendarData
 
 $calendars
 

Additional Inherited Members

- Protected Member Functions inherited from Sabre\CalDAV\Backend\AbstractBackend
 validateFilterForObject (array $object, array $filters)
 This method validates if a filter (as passed to calendarQuery) matches the given object. More...
 

Detailed Description

This is a mock CalDAV backend that supports subscriptions.

All data is retained in memory temporarily. It's primary purpose is unit-tests.

Author
Evert Pot (http://evertpot.com/) @license http://sabre.io/license/ Modified BSD License

Definition at line 18 of file MockSubscriptionSupport.php.

Member Function Documentation

◆ createSubscription()

Sabre\CalDAV\Backend\MockSubscriptionSupport::createSubscription (   $principalUri,
  $uri,
array  $properties 
)

Creates a new subscription for a principal.

If the creation was a success, an id must be returned that can be used to reference this subscription in other methods, such as updateSubscription.

Parameters
string$principalUri
string$uri
array$properties
Returns
mixed

Implements Sabre\CalDAV\Backend\SubscriptionSupport.

Definition at line 74 of file MockSubscriptionSupport.php.

74 {
75
76 $properties['uri'] = $uri;
77 $properties['principaluri'] = $principalUri;
78 $properties['source'] = $properties['{http://calendarserver.org/ns/}source']->getHref();
79
80 if (!isset($this->subs[$principalUri])) {
81 $this->subs[$principalUri] = [];
82 }
83
84 $id = [$principalUri, count($this->subs[$principalUri]) + 1];
85
86 $properties['id'] = $id;
87
88 $this->subs[$principalUri][] = array_merge($properties, [
89 'id' => $id,
90 ]);
91
92 return $id;
93
94 }
if(!array_key_exists('StateId', $_REQUEST)) $id

References $id.

◆ deleteSubscription()

Sabre\CalDAV\Backend\MockSubscriptionSupport::deleteSubscription (   $subscriptionId)

Deletes a subscription.

Parameters
mixed$subscriptionId
Returns
void

Implements Sabre\CalDAV\Backend\SubscriptionSupport.

Definition at line 141 of file MockSubscriptionSupport.php.

141 {
142
143 foreach ($this->subs[$subscriptionId[0]] as $index => $sub) {
144
145 if ($sub['id'][1] === $subscriptionId[1]) {
146 unset($this->subs[$subscriptionId[0]][$index]);
147 return true;
148 }
149
150 }
151
152 return false;
153
154 }
$index
Definition: metadata.php:60

References $index.

◆ getSubscriptionsForUser()

Sabre\CalDAV\Backend\MockSubscriptionSupport::getSubscriptionsForUser (   $principalUri)

Returns a list of subscriptions for a principal.

Every subscription is an array with the following keys:

  • id, a unique id that will be used by other functions to modify the subscription. This can be the same as the uri or a database key.
  • uri. This is just the 'base uri' or 'filename' of the subscription.
  • principaluri. The owner of the subscription. Almost always the same as principalUri passed to this method.
  • source. Url to the actual feed

Furthermore, all the subscription info must be returned too:

  1. {DAV:}displayname
  2. {http://apple.com/ns/ical/}refreshrate
  3. {http://calendarserver.org/ns/}subscribed-strip-todos (omit if todos should not be stripped).
  4. {http://calendarserver.org/ns/}subscribed-strip-alarms (omit if alarms should not be stripped).
  5. {http://calendarserver.org/ns/}subscribed-strip-attachments (omit if attachments should not be stripped).
  6. {http://apple.com/ns/ical/}calendar-color
  7. {http://apple.com/ns/ical/}calendar-order
Parameters
string$principalUri
Returns
array

Implements Sabre\CalDAV\Backend\SubscriptionSupport.

Definition at line 54 of file MockSubscriptionSupport.php.

54 {
55
56 if (isset($this->subs[$principalUri])) {
57 return $this->subs[$principalUri];
58 }
59 return [];
60
61 }

◆ updateSubscription()

Sabre\CalDAV\Backend\MockSubscriptionSupport::updateSubscription (   $subscriptionId,
DAV\PropPatch  $propPatch 
)

Updates a subscription.

The list of mutations is stored in a Sabre\DAV\PropPatch object. To do the actual updates, you must tell this object which properties you're going to process with the handle() method.

Calling the handle method is like telling the PropPatch object "I promise I can handle updating this property".

Read the PropPatch documentation for more info and examples.

Parameters
mixed$subscriptionId
\Sabre\DAV\PropPatch$propPatch
Returns
void

Implements Sabre\CalDAV\Backend\SubscriptionSupport.

Definition at line 112 of file MockSubscriptionSupport.php.

112 {
113
114 $found = null;
115 foreach ($this->subs[$subscriptionId[0]] as &$sub) {
116
117 if ($sub['id'][1] === $subscriptionId[1]) {
118 $found = & $sub;
119 break;
120 }
121
122 }
123
124 if (!$found) return;
125
126 $propPatch->handleRemaining(function($mutations) use (&$found) {
127 foreach ($mutations as $k => $v) {
128 $found[$k] = $v;
129 }
130 return true;
131 });
132
133 }

Field Documentation

◆ $subs

Sabre\CalDAV\Backend\MockSubscriptionSupport::$subs = []
protected

Definition at line 25 of file MockSubscriptionSupport.php.


The documentation for this class was generated from the following file: