1<?php 2 3namespace Sabre\CalDAV\Notifications; 4 5use Sabre\CalDAV; 6use Sabre\DAV; 7use Sabre\DAVACL; 8 9/** 10 * This node represents a list of notifications. 11 * 12 * It provides no additional functionality, but you must implement this 13 * interface to allow the Notifications plugin to mark the collection 14 * as a notifications collection. 15 * 16 * This collection should only return Sabre\CalDAV\Notifications\INode nodes as 17 * its children. 18 * 19 * @copyright Copyright (C) fruux GmbH (https://fruux.com/) 20 * @author Evert Pot (http://evertpot.com/) 21 * @license http://sabre.io/license/ Modified BSD License 22 */ 23class Collection extends DAV\Collection implements ICollection, DAVACL\IACL { 24 25 use DAVACL\ACLTrait; 26 27 /** 28 * The notification backend 29 * 30 * @var CalDAV\Backend\NotificationSupport 31 */ 32 protected $caldavBackend; 33 34 /** 35 * Principal uri 36 * 37 * @var string 38 */ 39 protected $principalUri; 40 41 /** 42 * Constructor 43 * 44 * @param CalDAV\Backend\NotificationSupport $caldavBackend 45 * @param string $principalUri 46 */ 47 function __construct(CalDAV\Backend\NotificationSupport $caldavBackend, $principalUri) { 48 49 $this->caldavBackend = $caldavBackend; 50 $this->principalUri = $principalUri; 51 52 } 53 54 /** 55 * Returns all notifications for a principal 56 * 57 * @return array 58 */ 59 function getChildren() { 60 61 $children = []; 62 $notifications = $this->caldavBackend->getNotificationsForPrincipal($this->principalUri); 63 64 foreach ($notifications as $notification) { 65 66 $children[] = new Node( 67 $this->caldavBackend, 68 $this->principalUri, 69 $notification 70 ); 71 } 72 73 return $children; 74 75 } 76 77 /** 78 * Returns the name of this object 79 * 80 * @return string 81 */ 82 function getName() { 83 84 return 'notifications'; 85 86 } 87 88 /** 89 * Returns the owner principal 90 * 91 * This must be a url to a principal, or null if there's no owner 92 * 93 * @return string|null 94 */ 95 function getOwner() { 96 97 return $this->principalUri; 98 99 } 100 101} 102