1<?php 2 3namespace Sabre\CardDAV; 4 5use Sabre\DAVACL; 6 7/** 8 * AddressBook rootnode 9 * 10 * This object lists a collection of users, which can contain addressbooks. 11 * 12 * @copyright Copyright (C) fruux GmbH (https://fruux.com/) 13 * @author Evert Pot (http://evertpot.com/) 14 * @license http://sabre.io/license/ Modified BSD License 15 */ 16class AddressBookRoot extends DAVACL\AbstractPrincipalCollection { 17 18 /** 19 * Principal Backend 20 * 21 * @var DAVACL\PrincipalBackend\BackendInterface 22 */ 23 protected $principalBackend; 24 25 /** 26 * CardDAV backend 27 * 28 * @var Backend\BackendInterface 29 */ 30 protected $carddavBackend; 31 32 /** 33 * Constructor 34 * 35 * This constructor needs both a principal and a carddav backend. 36 * 37 * By default this class will show a list of addressbook collections for 38 * principals in the 'principals' collection. If your main principals are 39 * actually located in a different path, use the $principalPrefix argument 40 * to override this. 41 * 42 * @param DAVACL\PrincipalBackend\BackendInterface $principalBackend 43 * @param Backend\BackendInterface $carddavBackend 44 * @param string $principalPrefix 45 */ 46 function __construct(DAVACL\PrincipalBackend\BackendInterface $principalBackend, Backend\BackendInterface $carddavBackend, $principalPrefix = 'principals') { 47 48 $this->carddavBackend = $carddavBackend; 49 parent::__construct($principalBackend, $principalPrefix); 50 51 } 52 53 /** 54 * Returns the name of the node 55 * 56 * @return string 57 */ 58 function getName() { 59 60 return Plugin::ADDRESSBOOK_ROOT; 61 62 } 63 64 /** 65 * This method returns a node for a principal. 66 * 67 * The passed array contains principal information, and is guaranteed to 68 * at least contain a uri item. Other properties may or may not be 69 * supplied by the authentication backend. 70 * 71 * @param array $principal 72 * @return \Sabre\DAV\INode 73 */ 74 function getChildForPrincipal(array $principal) { 75 76 return new AddressBookHome($this->carddavBackend, $principal['uri']); 77 78 } 79 80} 81