Detailed Description

NodeUtil provides services for the Node class.

All methods are static.

Author
ingo herwig ingo@.nosp@m.wemo.nosp@m.ve.co.nosp@m.m

Definition at line 28 of file NodeUtil.php.

Static Public Member Functions

static getConnections ($type, $otherRole, $otherType, $hierarchyType='all')
 
static getRelationQueryCondition ($node, $otherRole)
 
static getDisplayValue (Node $node, $language=null)
 
static getDisplayValues (Node $node, $language=null)
 
static makeNodeUrlsRelative (Node $node, $baseUrl, $recursive=true)
 
static translateValues (&$nodes, $language=null, $itemDelim=", ")
 
static translateValue (PersistentObject $object, $valueName, $language, $itemDelim=", ")
 
static removeNonDisplayValues (Node $node)
 
static removeNonPkValues (Node $node)
 

Static Protected Member Functions

static getConnectionsImpl ($type, $otherRole, $otherType, $hierarchyType, array &$result=[], array $currentPath=[])
 

Member Function Documentation

◆ getConnections()

static getConnections (   $type,
  $otherRole,
  $otherType,
  $hierarchyType = 'all' 
)
static

Get the shortest paths that connect a type to another type.

Parameters
$typeThe type to start from
$otherRoleThe role of the type at the other end (maybe null, if only type shoudl match)
$otherTypeThe type at the other end (maybe null, if only role shoudl match)
$hierarchyTypeThe hierarchy type that the other type has in relation to this type 'parent', 'child', 'undefined' or 'all' to get all relations (default: 'all')
Returns
An array of PathDescription instances

Definition at line 39 of file NodeUtil.php.

◆ getConnectionsImpl()

static getConnectionsImpl (   $type,
  $otherRole,
  $otherType,
  $hierarchyType,
array &  $result = [],
array  $currentPath = [] 
)
staticprotected

Get the relations that connect a type to another type.

Parameters
$typeThe type to start from
$otherRoleThe role of the type at the other end (maybe null, if only type shoudl match)
$otherTypeThe type at the other end (maybe null, if only role shoudl match)
$hierarchyTypeThe hierarchy type that the other type has in relation to this type 'parent', 'child', 'undefined' or 'all' to get all relations (default: 'all')
$resultArray of PathDescriptions after execution
$currentPathInternal use only

Definition at line 67 of file NodeUtil.php.

◆ getRelationQueryCondition()

static getRelationQueryCondition (   $node,
  $otherRole 
)
static

Get the query condition used to select all related Nodes of a given role.

Parameters
$nodeThe Node to select the relatives for
$otherRoleThe role of the other nodes
Returns
The condition string to be used with StringQuery.

Definition at line 117 of file NodeUtil.php.

◆ getDisplayValue()

static getDisplayValue ( Node  $node,
  $language = null 
)
static

Get the display value for a Node defined by the 'displayValues' property.

If the 'displayValues' property is an array the items will be put together with ' - '. If the 'displayValues' property is empty the function returns an empty string. Example: 'name,text' shows the name of the Node together with the content of the text attribute

Parameters
$nodeNode instance to display
$languageThe language if values should be localized. Optional, default is Localization::getDefaultLanguage()
Returns
String

Definition at line 152 of file NodeUtil.php.

◆ getDisplayValues()

static getDisplayValues ( Node  $node,
  $language = null 
)
static

Does the same as NodeUtil::getDisplayValue but returns the display values as associative array.

Parameters
$nodeNode instance to display
$languageThe language if values should be localized. Optional, default is Localization::getDefaultLanguage()
Returns
Array of strings

Definition at line 162 of file NodeUtil.php.

◆ makeNodeUrlsRelative()

static makeNodeUrlsRelative ( Node  $node,
  $baseUrl,
  $recursive = true 
)
static

Make all urls matching a given base url in a Node relative.

Parameters
$nodeNode instance that holds the value
$baseUrlThe baseUrl to which matching urls will be made relative
$recursiveBoolean whether to recurse into child Nodes or not (default: true)

Definition at line 202 of file NodeUtil.php.

◆ translateValues()

static translateValues ( $nodes,
  $language = null,
  $itemDelim = ", " 
)
static

Translate all list values in a list of Nodes.

Note
Translation in this case refers to mapping list values from the key to the value and should not be confused with localization, although values maybe localized using the language parameter.
Parameters
$nodesA reference to the array of Node instances
$languageThe language code, if the translated values should be localized. Optional, default is Localizat$objectgetDefaultLanguage()
$itemDelimDelimiter string for array values (optional, default: ", ")

Definition at line 249 of file NodeUtil.php.

◆ translateValue()

static translateValue ( PersistentObject  $object,
  $valueName,
  $language,
  $itemDelim = ", " 
)
static

Translate a PersistentObject list value.

Parameters
$objectThe object whose value to translate
$valueNameThe name of the value to translate
$languageThe language to use
$itemDelimDelimiter string for array values (optional, default: ", ")

Definition at line 266 of file NodeUtil.php.

◆ removeNonDisplayValues()

static removeNonDisplayValues ( Node  $node)
static

Remove all values from a Node that are not a display value.

Parameters
$nodeThe Node instance

Definition at line 278 of file NodeUtil.php.

◆ removeNonPkValues()

static removeNonPkValues ( Node  $node)
static

Remove all values from a Node that are not a primary key value.

Parameters
$nodeThe Node instance

Definition at line 292 of file NodeUtil.php.