aboutsummaryrefslogtreecommitdiffstats
path: root/vendor/sabre/dav/lib/DAV/Tree.php
diff options
context:
space:
mode:
Diffstat (limited to 'vendor/sabre/dav/lib/DAV/Tree.php')
-rw-r--r--vendor/sabre/dav/lib/DAV/Tree.php30
1 files changed, 18 insertions, 12 deletions
diff --git a/vendor/sabre/dav/lib/DAV/Tree.php b/vendor/sabre/dav/lib/DAV/Tree.php
index 8215e2c39..65b4583ce 100644
--- a/vendor/sabre/dav/lib/DAV/Tree.php
+++ b/vendor/sabre/dav/lib/DAV/Tree.php
@@ -16,7 +16,7 @@ use Sabre\Uri;
* @author Evert Pot (http://evertpot.com/)
* @license http://sabre.io/license/ Modified BSD License
*/
-class Tree
+class Tree implements INodeByPath
{
/**
* The root node.
@@ -62,20 +62,26 @@ class Tree
return $this->rootNode;
}
- // Attempting to fetch its parent
- list($parentName, $baseName) = Uri\split($path);
+ $parts = explode('/', $path);
+ $node = $this->rootNode;
- // If there was no parent, we must simply ask it from the root node.
- if ('' === $parentName) {
- $node = $this->rootNode->getChild($baseName);
- } else {
- // Otherwise, we recursively grab the parent and ask him/her.
- $parent = $this->getNodeForPath($parentName);
-
- if (!($parent instanceof ICollection)) {
+ while (count($parts)) {
+ if (!($node instanceof ICollection)) {
throw new Exception\NotFound('Could not find node at path: '.$path);
}
- $node = $parent->getChild($baseName);
+
+ if ($node instanceof INodeByPath) {
+ $targetNode = $node->getNodeForPath(implode('/', $parts));
+ if ($targetNode instanceof Node) {
+ $node = $targetNode;
+ break;
+ }
+ }
+
+ $part = array_shift($parts);
+ if ('' !== $part) {
+ $node = $node->getChild($part);
+ }
}
$this->cache[$path] = $node;