ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
Sabre\CalDAV\Backend\Mock Class Reference
+ Inheritance diagram for Sabre\CalDAV\Backend\Mock:
+ Collaboration diagram for Sabre\CalDAV\Backend\Mock:

Public Member Functions

 __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...
 

Protected Attributes

 $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

Definition at line 8 of file Mock.php.

Constructor & Destructor Documentation

◆ __construct()

Sabre\CalDAV\Backend\Mock::__construct ( array  $calendars = [],
array  $calendarData = [] 
)

Definition at line 13 of file Mock.php.

References $calendar, Sabre\CalDAV\Backend\Mock\$calendarData, Sabre\CalDAV\Backend\Mock\$calendars, and Sabre\DAV\UUIDUtil\getUUID().

13  {
14 
15  foreach ($calendars as &$calendar) {
16  if (!isset($calendar['id'])) {
17  $calendar['id'] = DAV\UUIDUtil::getUUID();
18  }
19  }
20 
21  $this->calendars = $calendars;
22  $this->calendarData = $calendarData;
23 
24  }
static getUUID()
Returns a pseudo-random v4 UUID.
Definition: UUIDUtil.php:26
+ Here is the call graph for this function:

Member Function Documentation

◆ createCalendar()

Sabre\CalDAV\Backend\Mock::createCalendar (   $principalUri,
  $calendarUri,
array  $properties 
)

Creates a new calendar for a principal.

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

This function must return a server-wide unique id that can be used later to reference the calendar.

Parameters
string$principalUri
string$calendarUri
array$properties
Returns
string|int

Implements Sabre\CalDAV\Backend\BackendInterface.

Definition at line 70 of file Mock.php.

References $id, Sabre\DAV\UUIDUtil\getUUID(), and Sabre\CalDAV\Plugin\NS_CALDAV.

70  {
71 
73  $this->calendars[] = array_merge([
74  'id' => $id,
75  'principaluri' => $principalUri,
76  'uri' => $calendarUri,
77  '{' . CalDAV\Plugin::NS_CALDAV . '}supported-calendar-component-set' => new CalDAV\Xml\Property\SupportedCalendarComponentSet(['VEVENT', 'VTODO']),
78  ], $properties);
79 
80  return $id;
81 
82  }
if(!array_key_exists('StateId', $_REQUEST)) $id
static getUUID()
Returns a pseudo-random v4 UUID.
Definition: UUIDUtil.php:26
const NS_CALDAV
This is the official CalDAV namespace.
Definition: Plugin.php:33
+ Here is the call graph for this function:

◆ createCalendarObject()

Sabre\CalDAV\Backend\Mock::createCalendarObject (   $calendarId,
  $objectUri,
  $calendarData 
)

Creates a new calendar object.

Parameters
string$calendarId
string$objectUri
string$calendarData
Returns
void

Implements Sabre\CalDAV\Backend\BackendInterface.

Definition at line 215 of file Mock.php.

References Sabre\CalDAV\Backend\Mock\$calendarData.

215  {
216 
217  $this->calendarData[$calendarId][$objectUri] = [
218  'calendardata' => $calendarData,
219  'calendarid' => $calendarId,
220  'uri' => $objectUri,
221  ];
222  return '"' . md5($calendarData) . '"';
223 
224  }

◆ deleteCalendar()

Sabre\CalDAV\Backend\Mock::deleteCalendar (   $calendarId)

Delete a calendar and all it's objects.

Parameters
string$calendarId
Returns
void

Implements Sabre\CalDAV\Backend\BackendInterface.

Definition at line 130 of file Mock.php.

References $calendar.

130  {
131 
132  foreach ($this->calendars as $k => $calendar) {
133  if ($calendar['id'] === $calendarId) {
134  unset($this->calendars[$k]);
135  }
136  }
137 
138  }

◆ deleteCalendarObject()

Sabre\CalDAV\Backend\Mock::deleteCalendarObject (   $calendarId,
  $objectUri 
)

Deletes an existing calendar object.

Parameters
string$calendarId
string$objectUri
Returns
void

Implements Sabre\CalDAV\Backend\BackendInterface.

Definition at line 252 of file Mock.php.

252  {
253 
254  unset($this->calendarData[$calendarId][$objectUri]);
255 
256  }

◆ getCalendarObject()

Sabre\CalDAV\Backend\Mock::getCalendarObject (   $calendarId,
  $objectUri 
)

Returns information from a single calendar object, based on it's object uri.

The object uri is only the basename, or filename and not a full path.

The returned array must have the same keys as getCalendarObjects. The 'calendardata' object is required here though, while it's not required for getCalendarObjects.

This method must return null if the object did not exist.

Parameters
mixed$calendarId
string$objectUri
Returns
array|null

Implements Sabre\CalDAV\Backend\BackendInterface.

Definition at line 194 of file Mock.php.

194  {
195 
196  if (!isset($this->calendarData[$calendarId][$objectUri])) {
197  return null;
198  }
199  $object = $this->calendarData[$calendarId][$objectUri];
200  $object['calendarid'] = $calendarId;
201  $object['uri'] = $objectUri;
202  $object['lastmodified'] = null;
203  return $object;
204 
205  }

◆ getCalendarObjects()

Sabre\CalDAV\Backend\Mock::getCalendarObjects (   $calendarId)

Returns all calendar objects within a calendar object.

Every item contains an array with the following keys:

  • id - unique identifier which will be used for subsequent updates
  • calendardata - The iCalendar-compatible calendar data
  • uri - a unique key which will be used to construct the uri. This can be any arbitrary string.
  • lastmodified - a timestamp of the last modification time
  • etag - An arbitrary string, surrounded by double-quotes. (e.g.: ' "abcdef"')
  • calendarid - The calendarid as it was passed to this function.

Note that the etag is optional, but it's highly encouraged to return for speed reasons.

The calendardata is also optional. If it's not returned 'getCalendarObject' will be called later, which is expected to return calendardata.

Parameters
string$calendarId
Returns
array

Implements Sabre\CalDAV\Backend\BackendInterface.

Definition at line 162 of file Mock.php.

162  {
163 
164  if (!isset($this->calendarData[$calendarId]))
165  return [];
166 
167  $objects = $this->calendarData[$calendarId];
168 
169  foreach ($objects as $uri => &$object) {
170  $object['calendarid'] = $calendarId;
171  $object['uri'] = $uri;
172  $object['lastmodified'] = null;
173  }
174  return $objects;
175 
176  }

◆ getCalendarsForUser()

Sabre\CalDAV\Backend\Mock::getCalendarsForUser (   $principalUri)

Returns a list of calendars for a principal.

Every project is an array with the following keys:

  • id, a unique id that will be used by other functions to modify the calendar. This can be the same as the uri or a database key.
  • uri, which the basename of the uri with which the calendar is accessed.
  • principalUri. The owner of the calendar. Almost always the same as principalUri passed to this method.

Furthermore it can contain webdav properties in clark notation. A very common one is '{DAV:}displayname'.

Parameters
string$principalUri
Returns
array

Implements Sabre\CalDAV\Backend\BackendInterface.

Definition at line 43 of file Mock.php.

References $r, and $row.

43  {
44 
45  $r = [];
46  foreach ($this->calendars as $row) {
47  if ($row['principaluri'] == $principalUri) {
48  $r[] = $row;
49  }
50  }
51 
52  return $r;
53 
54  }
$r
Definition: example_031.php:79
$row

◆ updateCalendar()

Sabre\CalDAV\Backend\Mock::updateCalendar (   $calendarId,
\Sabre\DAV\PropPatch  $propPatch 
)

Updates properties for a calendar.

The list of mutations is stored in a Sabre 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$calendarId
\Sabre\DAV\PropPatch$propPatch
Returns
void

Implements Sabre\CalDAV\Backend\BackendInterface.

Definition at line 100 of file Mock.php.

References $calendar.

100  {
101 
102  $propPatch->handleRemaining(function($props) use ($calendarId) {
103 
104  foreach ($this->calendars as $k => $calendar) {
105 
106  if ($calendar['id'] === $calendarId) {
107  foreach ($props as $propName => $propValue) {
108  if (is_null($propValue)) {
109  unset($this->calendars[$k][$propName]);
110  } else {
111  $this->calendars[$k][$propName] = $propValue;
112  }
113  }
114  return true;
115 
116  }
117 
118  }
119 
120  });
121 
122  }

◆ updateCalendarObject()

Sabre\CalDAV\Backend\Mock::updateCalendarObject (   $calendarId,
  $objectUri,
  $calendarData 
)

Updates an existing calendarobject, based on it's uri.

Parameters
string$calendarId
string$objectUri
string$calendarData
Returns
void

Implements Sabre\CalDAV\Backend\BackendInterface.

Definition at line 234 of file Mock.php.

References Sabre\CalDAV\Backend\Mock\$calendarData.

234  {
235 
236  $this->calendarData[$calendarId][$objectUri] = [
237  'calendardata' => $calendarData,
238  'calendarid' => $calendarId,
239  'uri' => $objectUri,
240  ];
241  return '"' . md5($calendarData) . '"';
242 
243  }

Field Documentation

◆ $calendarData

◆ $calendars

Sabre\CalDAV\Backend\Mock::$calendars
protected

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