summaryrefslogtreecommitdiffstats
path: root/3rdparty/Sabre/DAV/SimpleCollection.php
diff options
context:
space:
mode:
authorGeorg Ehrke <dev@georgswebsite.de>2012-07-20 15:25:36 +0200
committerGeorg Ehrke <dev@georgswebsite.de>2012-07-20 15:25:36 +0200
commitbd91ee4d2289b15fa69c3712056f275cac3405ed (patch)
treebc2ad997c5565362cb7c99e61efbd1cb069fb9be /3rdparty/Sabre/DAV/SimpleCollection.php
parente4154e68324fd9af4c7ba0b9abba3e50d5b5c56e (diff)
downloadnextcloud-server-bd91ee4d2289b15fa69c3712056f275cac3405ed.tar.gz
nextcloud-server-bd91ee4d2289b15fa69c3712056f275cac3405ed.zip
add SabreDav 1.6.3 files
Diffstat (limited to '3rdparty/Sabre/DAV/SimpleCollection.php')
-rwxr-xr-x3rdparty/Sabre/DAV/SimpleCollection.php105
1 files changed, 105 insertions, 0 deletions
diff --git a/3rdparty/Sabre/DAV/SimpleCollection.php b/3rdparty/Sabre/DAV/SimpleCollection.php
new file mode 100755
index 00000000000..4acf971caa5
--- /dev/null
+++ b/3rdparty/Sabre/DAV/SimpleCollection.php
@@ -0,0 +1,105 @@
+<?php
+
+/**
+ * SimpleCollection
+ *
+ * The SimpleCollection is used to quickly setup static directory structures.
+ * Just create the object with a proper name, and add children to use it.
+ *
+ * @package Sabre
+ * @subpackage DAV
+ * @copyright Copyright (C) 2007-2012 Rooftop Solutions. All rights reserved.
+ * @author Evert Pot (http://www.rooftopsolutions.nl/)
+ * @license http://code.google.com/p/sabredav/wiki/License Modified BSD License
+ */
+class Sabre_DAV_SimpleCollection extends Sabre_DAV_Collection {
+
+ /**
+ * List of childnodes
+ *
+ * @var array
+ */
+ protected $children = array();
+
+ /**
+ * Name of this resource
+ *
+ * @var string
+ */
+ protected $name;
+
+ /**
+ * Creates this node
+ *
+ * The name of the node must be passed, child nodes can also be bassed.
+ * This nodes must be instances of Sabre_DAV_INode
+ *
+ * @param string $name
+ * @param array $children
+ */
+ public function __construct($name,array $children = array()) {
+
+ $this->name = $name;
+ foreach($children as $child) {
+
+ if (!($child instanceof Sabre_DAV_INode)) throw new Sabre_DAV_Exception('Only instances of Sabre_DAV_INode are allowed to be passed in the children argument');
+ $this->addChild($child);
+
+ }
+
+ }
+
+ /**
+ * Adds a new childnode to this collection
+ *
+ * @param Sabre_DAV_INode $child
+ * @return void
+ */
+ public function addChild(Sabre_DAV_INode $child) {
+
+ $this->children[$child->getName()] = $child;
+
+ }
+
+ /**
+ * Returns the name of the collection
+ *
+ * @return string
+ */
+ public function getName() {
+
+ return $this->name;
+
+ }
+
+ /**
+ * Returns a child object, by its name.
+ *
+ * This method makes use of the getChildren method to grab all the child nodes, and compares the name.
+ * Generally its wise to override this, as this can usually be optimized
+ *
+ * @param string $name
+ * @throws Sabre_DAV_Exception_NotFound
+ * @return Sabre_DAV_INode
+ */
+ public function getChild($name) {
+
+ if (isset($this->children[$name])) return $this->children[$name];
+ throw new Sabre_DAV_Exception_NotFound('File not found: ' . $name . ' in \'' . $this->getName() . '\'');
+
+ }
+
+ /**
+ * Returns a list of children for this collection
+ *
+ * @return array
+ */
+ public function getChildren() {
+
+ return array_values($this->children);
+
+ }
+
+
+}
+