ApiOpenStudio PHPDoc

TreeParser
in package

Class TreeParser

Crawl through the processor node tree, using depth-first iteration.

The parser stores all un-processed nodes in $processingStack. Where a node has children, each child is placed at the head of the stack so that it can be processed before the parent.

Node results are placed into $resultStack.

Once a parent node has been calculated, it's value is placed in the $resultStack, and it's children results are removed from $resultStack.

The crawler needs to also take into account conditional nodes. These branches should only be traversed, based on the parent comparison results. This save unnecessary calculation of redundant branches. These nodes are placed in the jitStack, and will only be processed once all the nodes in the $processingStack have been cleared.

Table of Contents

$cache  : Cache
ApiOpenStudio Cache instance.
$db  : ADOConnection
DB connection object.
$helper  : ProcessorHelper
Processor helper class.
$logger  : MonologWrapper
Logging class.
$processingStack  : array<string|int, mixed>
Stack of nodes to be processed.
$request  : Request
This request.
$resultStack  : array<string|int, mixed>
Stack of processed node results.
__construct()  : mixed
Constructor.
addToResultStack()  : void
Add a value to thew result stack, indexed by its ID.
crawlMeta()  : mixed
Process the metadata, using depth first iteration.
getFromResultStack()  : mixed|null
Fetch a value from the result stack.
popFromProcessingStack()  : mixed|null
Fetch the element from the end of the processingStack.
processingStackEmpty()  : bool
Returns if the processing stack is empty.
pushToProcessingStack()  : void
Append a node tree structure to the end of the processingStack.
setRequest()  : void
Update the request object.
getInputsHash()  : string|null
Return a hash of all calculated inputs.
getProcessorCache()  : DataContainer|null
Fetch a processor result from cache. Null is returned if no results.
processNode()  : void
Attempt to process a node from the stack. If the required attributes are not yet calculated, re-add to the unprocessed stack followed by the unprocessed attributes.
reprocessAfterChildren()  : void
Pre-process a node's children.
setProcessorCache()  : bool
Store a processor result in cache.

Properties

$db

DB connection object.

protected ADOConnection $db

$processingStack

Stack of nodes to be processed.

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

$resultStack

Stack of processed node results.

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

Methods

addToResultStack()

Add a value to thew result stack, indexed by its ID.

public addToResultStack( $id,  $val) : void
Parameters
$id :

ID/Key for the result item.

$val :

Value for the result item.

Return values
void

crawlMeta()

Process the metadata, using depth first iteration.

public crawlMeta() : mixed
Tags
throws
ApiException
Return values
mixed

getFromResultStack()

Fetch a value from the result stack.

public getFromResultStack( $id) : mixed|null

This will remove it from the result stack.

Parameters
$id :
Return values
mixed|null

Result value.

popFromProcessingStack()

Fetch the element from the end of the processingStack.

public popFromProcessingStack() : mixed|null
Return values
mixed|null

Value from the stack to be processed.

processingStackEmpty()

Returns if the processing stack is empty.

public processingStackEmpty() : bool
Return values
bool

Processing stack is empty.

pushToProcessingStack()

Append a node tree structure to the end of the processingStack.

public pushToProcessingStack(array<string|int, mixed> $tree) : void
Parameters
$tree : array<string|int, mixed>

Node tree to add to the stack.

Return values
void

setRequest()

Update the request object.

public setRequest(Request $request) : void
Parameters
$request : Request
Return values
void

getInputsHash()

Return a hash of all calculated inputs.

protected getInputsHash(array<string|int, mixed> $node) : string|null
Parameters
$node : array<string|int, mixed>
Return values
string|null

getProcessorCache()

Fetch a processor result from cache. Null is returned if no results.

protected getProcessorCache(array<string|int, mixed> $node) : DataContainer|null
Parameters
$node : array<string|int, mixed>

Metadata for the node to fetch from cache.

Tags
throws
ApiException
Return values
DataContainer|null

processNode()

Attempt to process a node from the stack. If the required attributes are not yet calculated, re-add to the unprocessed stack followed by the unprocessed attributes.

protected processNode(array<string|int, mixed> $node) : void
Parameters
$node : array<string|int, mixed>

Metadata for the node to process.

Tags
throws
ApiException
Return values
void

reprocessAfterChildren()

Pre-process a node's children.

protected reprocessAfterChildren(array<string|int, mixed> $node, array<string|int, mixed> $childNodes) : void
Parameters
$node : array<string|int, mixed>
$childNodes : array<string|int, mixed>
Return values
void

setProcessorCache()

Store a processor result in cache.

protected setProcessorCache(array<string|int, mixed> $node, array<string|int, mixed>|DataContainer $data) : bool
Parameters
$node : array<string|int, mixed>

Metadata for the node to fetch from cache.

$data : array<string|int, mixed>|DataContainer

Result data to store.

Tags
throws
ApiException
Return values
bool

Search results