56 if (isset($this->cache[
$path]))
return $this->cache[
$path];
67 if ($parentName ===
"") {
68 $node = $this->rootNode->getChild($baseName);
74 throw new Exception\NotFound(
'Could not find node at path: ' . $path);
76 $node = $parent->getChild($baseName);
80 $this->cache[
$path] = $node;
99 if (
$path ===
'')
return true;
104 if (!$parentNode instanceof
ICollection)
return false;
105 return $parentNode->childExists(
$base);
122 function copy($sourcePath, $destinationPath) {
130 $this->
copyNode($sourceNode, $destinationParent, $destinationName);
143 function move($sourcePath, $destinationPath) {
151 $sourceNode->setName($destinationName);
154 $moveSuccess =
false;
158 $moveSuccess = $newParentNode->moveInto($destinationName, $sourcePath, $sourceNode);
161 $this->
copy($sourcePath, $destinationPath);
195 $children = $node->getChildren();
196 $basePath = trim(
$path,
'/');
197 if ($basePath !==
'') $basePath .=
'/';
199 foreach ($children as $child) {
201 $this->cache[$basePath . $child->getName()] = $child;
231 foreach ($this->cache as $nodePath => $node) {
232 if (
$path ===
'' || $nodePath ==
$path || strpos($nodePath,
$path .
'/') === 0)
233 unset($this->cache[$nodePath]);
259 if (!isset($parents[$parent])) {
260 $parents[$parent] = [$node];
262 $parents[$parent][] = $node;
268 foreach ($parents as $parent => $children) {
272 foreach ($parentNode->getMultipleChildren($children) as $childNode) {
273 $fullPath = $parent .
'/' . $childNode->getName();
274 $result[$fullPath] = $childNode;
275 $this->cache[$fullPath] = $childNode;
278 foreach ($children as $child) {
279 $fullPath = $parent .
'/' . $child;
301 if (!$destinationName) $destinationName = $source->
getName();
303 if ($source instanceof
IFile) {
305 $data = $source->get();
308 if (is_string(
$data)) {
322 foreach ($source->getChildren() as $child) {
331 $props = $source->getProperties([]);
334 $propPatch->commit();
nodeExists($path)
This function allows you to check if a node exists.
getName()
Returns the name of the node.
This class represents a set of properties that are going to be updated.
copy($sourcePath, $destinationPath)
Copies a file from path to another.
getNodeForPath($path)
Returns the INode object for the requested path.
$stream
PHP stream implementation.
The ICollection Interface.
getMultipleNodes($paths)
This method tells the tree system to pre-fetch and cache a list of children of a single parent...
By implementing this interface, a collection can effectively say "other nodes may be moved into this ...
This interface represents a file in the directory tree.
The INode interface is the base interface, and the parent class of both ICollection and IFile...
move($sourcePath, $destinationPath)
Moves a file from one location to another.
getChildren($path)
Returns a list of childnodes for a given path.
markDirty($path)
This method is called with every tree update.
copyNode(INode $source, ICollection $destinationParent, $destinationName=null)
copyNode
createFile($name, $data=null)
Creates a new file in the directory.
__construct(ICollection $rootNode)
Creates the object.
createDirectory($name)
Creates a new subdirectory.
getChild($name)
Returns a specific child node, referenced by its name.
static splitPath($path)
Returns the 'dirname' and 'basename' for a path.
The tree object is responsible for basic tree operations.