setasign\SetaPDF2\Core\DataStructure\Tree
NameTree Data structure class for Name Trees
File: /SetaPDF v2/Core/DataStructure/Tree/NameTree.php
Old class name (alias):
\SetaPDF_Core_DataStructure_NameTree
Class hierarchy
Implements
Summary
Static Properties
Properties
$_document
The document to which the tree depends to
$_values
A cache for resolved entries
The index is the key while the value is an array of both key and value object.
Static Methods
adjustNameCallback()
Callback function to build unique names.
Parameters
- $name : string
- $i : string
Attempt count
Methods
__construct()
The constructor.
Parameters
- $rootDictionary : \SetaPDF_Core_Type_Dictionary
- $document : \SetaPDF_Core_Document
_findLastLeafNode()
Finds the last leaf node.
Parameters
- $node : \SetaPDF_Core_Type_Dictionary
- $intermediateNodes : array
Exceptions
_findLeaveNodeByKey()
int $key,
bool $exactMatch = true,
array &$intermediateNodes = array ( ),
&$kidsInfo = array ( )
Find a appropriate leaf node by a key.
Parameters
- $node : \SetaPDF_Core_Type_Dictionary
- $key : int
- $exactMatch : bool
- $intermediateNodes : array
- $kidsInfo
Exceptions
_get()
Gets a key value pair by a root node and a key.
Parameters
- $node : \SetaPDF_Core_Type_Dictionary
- $key : string
Exceptions
_getBlankLeafNodeObject()
Helper method to create a blank leaf node
Parameters
- $intermediate : bool
add()
Add a keyed value to the tree.
For name trees: Make sure you pass the name in PDFDocEncoding or UTF-16BE including BOM.
Parameters
- $key : int|string|\SetaPDF_Core_Type_ScalarValue
Depends on the implementation
- $value : \SetaPDF_Core_Type_AbstractType
Exceptions
Throws KeyAlreadyExistsException
Throws \setasign\SetaPDF2\Core\Type\Exception
See
cleanUp()
Release objects to free memory and cycled references
After calling this method the instance of this object is unusable!
get()
string $className = null
Get an object by a key.
Parameters
- $key : string|int
- $className : string
Exceptions
merge()
Merges another tree into this tree.
As all items have to be unique this method will call a callback function given in $alreadyExistsCallback if an item already exists.
Parameters
- $tree : \SetaPDF_Core_DataStructure_Tree
- $alreadyExistsCallback : ?callback
Will be called if a item already exists.
This method can take control over the renaming of the item. The method will be called as long as it will not throw an exception of KeyAlreadyExistsException.
The parameter of the callback function are: The key value and an incremental number of renaming attempts.
Return Values
An array of renamed items
Exceptions
Throws KeyAlreadyExistsException
toPhp()
Returns an array with named keys and name values
Exceptions
Throws \setasign\SetaPDF2\Core\Type\Exception