<?php
-class Sabre_CalDAV_Backend_Mock extends Sabre_CalDAV_Backend_Abstract {
+class Sabre_CalDAV_Backend_Mock extends Sabre_CalDAV_Backend_Abstract implements Sabre_CalDAV_Backend_NotificationSupport {
private $calendarData;
private $calendars;
+ private $notifications;
- function __construct(array $calendars, array $calendarData) {
+ function __construct(array $calendars, array $calendarData, array $notifications = array()) {
$this->calendars = $calendars;
$this->calendarData = $calendarData;
+ $this->notifications = $notifications;
}
*/
function createCalendar($principalUri,$calendarUri,array $properties) {
- throw new Exception('Not implemented');
+ $id = Sabre_DAV_UUIDUtil::getUUID();
+ $this->calendars[] = array_merge(array(
+ 'id' => $id,
+ 'principaluri' => $principalUri,
+ 'uri' => $calendarUri,
+ '{' . Sabre_CalDAV_Plugin::NS_CALDAV . '}supported-calendar-component-set' => new Sabre_CalDAV_Property_SupportedCalendarComponentSet(array('VEVENT','VTODO')),
+ ), $properties);
+
+ return $id;
}
*/
public function deleteCalendar($calendarId) {
- throw new Exception('Not implemented');
+ foreach($this->calendars as $k=>$calendar) {
+ if ($calendar['id'] === $calendarId) {
+ unset($this->calendars[$k]);
+ }
+ }
}
}
+ /**
+ * Returns a list of notifications for a given principal url.
+ *
+ * The returned array should only consist of implementations of
+ * Sabre_CalDAV_Notifications_INotificationType.
+ *
+ * @param string $principalUri
+ * @return array
+ */
+ public function getNotificationsForPrincipal($principalUri) {
+
+ if (isset($this->notifications[$principalUri])) {
+ return $this->notifications[$principalUri];
+ }
+ return array();
+
+ }
+
+ /**
+ * This deletes a specific notifcation.
+ *
+ * This may be called by a client once it deems a notification handled.
+ *
+ * @param string $principalUri
+ * @param Sabre_CalDAV_Notifications_INotificationType $notification
+ * @return void
+ */
+ public function deleteNotification($principalUri, Sabre_CalDAV_Notifications_INotificationType $notification) {
+
+ throw new Sabre_DAV_Exception_NotImplemented('This doesn\'t work!');
+
+ }
+
}