56 if (isset($this->cache[
$path]))
return $this->cache[
$path];
67 if ($parentName ===
"") {
68 $node = $this->rootNode->getChild($baseName);
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();
308 if (is_string(
$data)) {
309 $stream = fopen(
'php://temp',
'r+');
322 foreach (
$source->getChildren() as $child) {
331 $props =
$source->getProperties([]);
334 $propPatch->commit();
An exception for terminatinating execution or to throw for unit testing.
This class represents a set of properties that are going to be updated.
The tree object is responsible for basic tree operations.
getChildren($path)
Returns a list of childnodes for a given path.
copy($sourcePath, $destinationPath)
Copies a file from path to another.
__construct(ICollection $rootNode)
Creates the object.
getMultipleNodes($paths)
This method tells the tree system to pre-fetch and cache a list of children of a single parent.
getNodeForPath($path)
Returns the INode object for the requested path.
markDirty($path)
This method is called with every tree update.
copyNode(INode $source, ICollection $destinationParent, $destinationName=null)
copyNode
nodeExists($path)
This function allows you to check if a node exists.
move($sourcePath, $destinationPath)
Moves a file from one location to another.
static splitPath($path)
Returns the 'dirname' and 'basename' for a path.
The ICollection Interface.
getChild($name)
Returns a specific child node, referenced by its name.
createDirectory($name)
Creates a new subdirectory.
createFile($name, $data=null)
Creates a new file in the directory.
This interface represents a file in the directory tree.
By implementing this interface, a collection can effectively say "other nodes may be moved into this ...
The INode interface is the base interface, and the parent class of both ICollection and IFile.
$stream
PHP stream implementation.