ILIAS  release_5-4 Revision v5.4.26-12-gabc799a52e6
AbstractPrincipalCollection.php
Go to the documentation of this file.
1 <?php
2 
3 namespace Sabre\DAVACL;
4 
5 use Sabre\DAV;
7 
21 
27  protected $principalBackend;
28 
34  protected $principalPrefix;
35 
42  public $disableListing = false;
43 
56  function __construct(PrincipalBackend\BackendInterface $principalBackend, $principalPrefix = 'principals') {
57 
58  $this->principalPrefix = $principalPrefix;
59  $this->principalBackend = $principalBackend;
60 
61  }
62 
73  abstract function getChildForPrincipal(array $principalInfo);
74 
80  function getName() {
81 
82  list(, $name) = URLUtil::splitPath($this->principalPrefix);
83  return $name;
84 
85  }
86 
92  function getChildren() {
93 
94  if ($this->disableListing)
95  throw new DAV\Exception\MethodNotAllowed('Listing members of this collection is disabled');
96 
97  $children = [];
98  foreach ($this->principalBackend->getPrincipalsByPrefix($this->principalPrefix) as $principalInfo) {
99 
100  $children[] = $this->getChildForPrincipal($principalInfo);
101 
102 
103  }
104  return $children;
105 
106  }
107 
115  function getChild($name) {
116 
117  $principalInfo = $this->principalBackend->getPrincipalByPath($this->principalPrefix . '/' . $name);
118  if (!$principalInfo) throw new DAV\Exception\NotFound('Principal with name ' . $name . ' not found');
119  return $this->getChildForPrincipal($principalInfo);
120 
121  }
122 
146  function searchPrincipals(array $searchProperties, $test = 'allof') {
147 
148  $result = $this->principalBackend->searchPrincipals($this->principalPrefix, $searchProperties, $test);
149  $r = [];
150 
151  foreach ($result as $row) {
152  list(, $r[]) = URLUtil::splitPath($row);
153  }
154 
155  return $r;
156 
157  }
158 
175  function findByUri($uri) {
176 
177  return $this->principalBackend->findByUri($uri, $this->principalPrefix);
178 
179  }
180 
181 }
$result
getName()
Returns the name of this collection.
searchPrincipals(array $searchProperties, $test='allof')
This method is used to search for principals matching a set of properties.
Principal Collection interface.
Collection class.
Definition: Collection.php:15
findByUri($uri)
Finds a principal by its URI.
$r
Definition: example_031.php:79
getChild($name)
Returns a child object, by its name.
$row
__construct(PrincipalBackend\BackendInterface $principalBackend, $principalPrefix='principals')
Creates the object.
getChildForPrincipal(array $principalInfo)
This method returns a node for a principal.
static splitPath($path)
Returns the &#39;dirname&#39; and &#39;basename&#39; for a path.
Definition: URLUtil.php:83
$test
Definition: Utf8Test.php:84