Documentation

TreeMock extends Tree
in package

The tree object is responsible for basic tree operations.

It allows for fetching nodes by path, facilitates deleting, copying and moving.

Table of Contents

$cache  : array<string|int, mixed>
This is the node cache. Accessed nodes are stored here.
$rootNode  : ICollection
The root node.
$nodes  : mixed
__construct()  : mixed
Creates the object.
copy()  : mixed
Copies a file from path to another.
delete()  : mixed
Deletes a node from the tree.
getChildren()  : Traversable
Returns a list of childnodes for a given path.
getMultipleNodes()  : array<string|int, mixed>
This method tells the tree system to pre-fetch and cache a list of children of a single parent.
getNodeForPath()  : INode
Returns the INode object for the requested path.
markDirty()  : mixed
This method is called with every tree update.
move()  : int
Moves a file from one location to another.
nodeExists()  : bool
This function allows you to check if a node exists.
copyNode()  : mixed
copyNode.

Properties

$cache

This is the node cache. Accessed nodes are stored here.

protected array<string|int, mixed> $cache = []

Arrays keys are path names, values are the actual nodes.

Methods

__construct()

Creates the object.

public __construct() : mixed

This method expects the rootObject to be passed as a parameter

Return values
mixed

copy()

Copies a file from path to another.

public copy(string $sourcePath, string $destinationPath) : mixed
Parameters
$sourcePath : string

The source location

$destinationPath : string

The full destination path

Return values
mixed

delete()

Deletes a node from the tree.

public delete(string $path) : mixed
Parameters
$path : string
Return values
mixed

getChildren()

Returns a list of childnodes for a given path.

public getChildren(string $path) : Traversable
Parameters
$path : string
Return values
Traversable

getMultipleNodes()

This method tells the tree system to pre-fetch and cache a list of children of a single parent.

public getMultipleNodes(array<string|int, mixed> $paths) : array<string|int, mixed>

There are a bunch of operations in the WebDAV stack that request many children (based on uris), and sometimes fetching many at once can optimize this.

This method returns an array with the found nodes. It's keys are the original paths. The result may be out of order.

Parameters
$paths : array<string|int, mixed>

list of nodes that must be fetched

Return values
array<string|int, mixed>

getNodeForPath()

Returns the INode object for the requested path.

public getNodeForPath(string $path) : INode
Parameters
$path : string
Return values
INode

markDirty()

This method is called with every tree update.

public markDirty(string $path) : mixed

Examples of tree updates are:

  • node deletions
  • node creations
  • copy
  • move
  • renaming nodes

If Tree classes implement a form of caching, this will allow them to make sure caches will be expired.

If a path is passed, it is assumed that the entire subtree is dirty

Parameters
$path : string
Return values
mixed

move()

Moves a file from one location to another.

public move(string $sourcePath, string $destinationPath) : int
Parameters
$sourcePath : string

The path to the file which should be moved

$destinationPath : string

The full destination path, so not just the destination parent node

Return values
int

nodeExists()

This function allows you to check if a node exists.

public nodeExists(string $path) : bool

Implementors of this class should override this method to make it cheaper.

Parameters
$path : string
Return values
bool

copyNode()

copyNode.

protected copyNode(INode $source, ICollection $destinationParent[, string $destinationName = null ]) : mixed
Parameters
$source : INode
$destinationParent : ICollection
$destinationName : string = null
Return values
mixed

Search results