1<?php 2 3namespace Sabre\DAVACL\PrincipalBackend; 4 5/** 6 * Abstract Principal Backend 7 * 8 * Currently this class has no function. It's here for consistency and so we 9 * have a non-bc-breaking way to add a default generic implementation to 10 * functions we may add in the future. 11 * 12 * @copyright Copyright (C) 2007-2015 fruux GmbH (https://fruux.com/). 13 * @author Evert Pot (http://evertpot.com/) 14 * @license http://sabre.io/license/ Modified BSD License 15 */ 16abstract class AbstractBackend implements BackendInterface { 17 18 /** 19 * Finds a principal by its URI. 20 * 21 * This method may receive any type of uri, but mailto: addresses will be 22 * the most common. 23 * 24 * Implementation of this API is optional. It is currently used by the 25 * CalDAV system to find principals based on their email addresses. If this 26 * API is not implemented, some features may not work correctly. 27 * 28 * This method must return a relative principal path, or null, if the 29 * principal was not found or you refuse to find it. 30 * 31 * @param string $uri 32 * @param string $principalPrefix 33 * @return string 34 */ 35 function findByUri($uri, $principalPrefix) { 36 37 // Note that the default implementation here is a bit slow and could 38 // likely be optimized. 39 if (substr($uri, 0, 7) !== 'mailto:') { 40 return; 41 } 42 $result = $this->searchPrincipals( 43 $principalPrefix, 44 ['{http://sabredav.org/ns}email-address' => substr($uri, 7)] 45 ); 46 47 if ($result) { 48 return $result[0]; 49 } 50 51 } 52 53} 54