NodePathHelper
in package
uses
DatabaseTrait
Class NodePathHelper
Helper class for FQN/Display/Relative Name operations. This class centralizes all path manipulation functionality that was previously part of the Node class.
Table of Contents
Properties
- $error_message : string
Methods
- configErrorMessage() : string
- Returns the configuration error message.
- createFriendlyPaths() : array<string|int, mixed>
- Creates a display-friendly reduced path name for a set of nodes.
- getConfig() : TiqConfig
- Gets the TIQ configuration.
- getDb() : PgSQL
- Gets database instance.
- getFQN() : string
- Returns a human-readable FQN for a node.
- getFQNDisplayPath() : array<string|int, mixed>|array<string|int, string>
- This is a bulk operation to fetch FQN display paths for multiple nodes.
- getPathComponents() : array<string|int, mixed>
- Gets the parent path components for a node.
- isDebug() : bool
- Is debug mode or not.
- isParentPath() : bool
- Checks if one path is a parent of another path.
- reduceFQN() : array<string|int, mixed>
- Reduces FQN paths to make them more readable by eliminating common prefixes when possible, helping to create more concise path displays for the UI.
Properties
$error_message
public
static string
$error_message
= 'An issue occurred, please contact ThinkIQ for Support and enable debugging'
- Base error message
Methods
configErrorMessage()
Returns the configuration error message.
public
static configErrorMessage() : string
Return values
stringcreateFriendlyPaths()
Creates a display-friendly reduced path name for a set of nodes.
public
static createFriendlyPaths(array<string|int, mixed> $nodeIds[, string $delimiter = '.' ]) : array<string|int, mixed>
Useful when displaying multiple nodes in a UI context.
Parameters
- $nodeIds : array<string|int, mixed>
-
Array of node IDs to create friendly paths for
- $delimiter : string = '.'
-
The delimiter to use in paths
Return values
array<string|int, mixed> —Array of node IDs mapped to their friendly path names
getConfig()
Gets the TIQ configuration.
public
static getConfig() : TiqConfig
Return values
TiqConfiggetDb()
Gets database instance.
public
static getDb() : PgSQL
The database connection is stored in a static property within the DatabaseConnectionManager class, ensuring that it is truly a singleton across the entire application, regardless of which class calls this method.
Return values
PgSQLgetFQN()
Returns a human-readable FQN for a node.
public
static getFQN(Node $node[, string $delimiter = '.' ][, bool $use_display_names = false ]) : string
Parameters
- $node : Node
-
The node to get FQN for
- $delimiter : string = '.'
-
Optional parameter to separate the relative names.
- $use_display_names : bool = false
-
Optional parameter to return display names instead of relative names.
Return values
string —The formatted path string
getFQNDisplayPath()
This is a bulk operation to fetch FQN display paths for multiple nodes.
public
static getFQNDisplayPath(array<string|int, mixed> $ids[, string $delimiter = '.' ][, bool $reduce = true ]) : array<string|int, mixed>|array<string|int, string>
Parameters
- $ids : array<string|int, mixed>
-
Array of Node ids.
- $delimiter : string = '.'
-
Optional parameter to separate the relative names.
- $reduce : bool = true
-
Dictates whether to reduce the Node path or not.
Return values
array<string|int, mixed>|array<string|int, string> —Array of path information
getPathComponents()
Gets the parent path components for a node.
public
static getPathComponents(int $nodeId) : array<string|int, mixed>
Parameters
- $nodeId : int
-
The ID of the node to get parent components for
Return values
array<string|int, mixed> —Array of parent components ordered from root to node
isDebug()
Is debug mode or not.
public
static isDebug() : bool
Return values
boolisParentPath()
Checks if one path is a parent of another path.
public
static isParentPath(string $parentPath, string $childPath[, string $delimiter = '.' ]) : bool
Parameters
- $parentPath : string
-
The potential parent path
- $childPath : string
-
The potential child path
- $delimiter : string = '.'
-
The path delimiter
Return values
bool —True if parentPath is a parent of childPath
reduceFQN()
Reduces FQN paths to make them more readable by eliminating common prefixes when possible, helping to create more concise path displays for the UI.
public
static reduceFQN(array<string|int, mixed> $paths[, string $delimiter = '.' ]) : array<string|int, mixed>
This function requires that each entry in the array $paths is and array itself with the keys 'id' and 'path'
Parameters
- $paths : array<string|int, mixed>
-
A multidimensional array that contains paths and ids we want to reduce.
- $delimiter : string = '.'
-
Optional parameter to separate the relative names.
Return values
array<string|int, mixed> —The reduced paths