Drupal 8  8.0.2
MenuTreeParameters Class Reference

Public Member Functions

 setRoot ($root)
 
 setMinDepth ($min_depth)
 
 setMaxDepth ($max_depth)
 
 addExpandedParents (array $parents)
 
 setActiveTrail (array $active_trail)
 
 addCondition ($definition_field, $value, $operator=NULL)
 
 onlyEnabledLinks ()
 
 setTopLevelOnly ()
 
 excludeRoot ()
 

Data Fields

 $root = ''
 
 $minDepth = NULL
 
 $maxDepth = NULL
 
 $expandedParents = array()
 
 $activeTrail = array()
 
 $conditions = array()
 

Detailed Description

Provides a value object to model menu tree parameters.

Menu tree parameters are used to determine the set of definitions to be loaded from . Hence they determine the shape and content of the tree:

  • Which parent IDs should be used to restrict the tree. Only links with a parent in the list will be included.
  • Which menu links are omitted, depending on the minimum and maximum depth.

Member Function Documentation

addCondition (   $definition_field,
  $value,
  $operator = NULL 
)

Adds a custom query condition.

Parameters
string$definition_fieldOnly conditions that are testing menu link definition fields are allowed.
mixed$valueThe value to test the link definition field against. In most cases, this is a scalar. For more complex options, it is an array. The meaning of each element in the array is dependent on the $operator.
string | null$operator(optional) The comparison operator, such as =, <, or >=. It also accepts more complex options such as IN, LIKE, or BETWEEN. If NULL, defaults to the = operator.
Returns
$this

Referenced by MenuTreeParameters\onlyEnabledLinks().

Here is the caller graph for this function:

addExpandedParents ( array  $parents)

Adds parent menu links IDs to restrict the tree.

Parameters
string[]$parents An array containing parent IDs. If supplied, the tree is limited to links that have these parents.
Returns
$this
excludeRoot ( )

Excludes the root menu link from the tree.

Note that this is only necessary when you specified a custom root, because the normal root ID is the empty string, '', which does not correspond to an actual menu link. Hence when loading a menu link tree without specifying a custom root the tree will start at the children even if this method has not been called.

Returns
$this

References MenuTreeParameters\setMinDepth().

Here is the call graph for this function:

onlyEnabledLinks ( )

Excludes links that are not enabled.

Returns
$this

References MenuTreeParameters\addCondition().

Here is the call graph for this function:

setActiveTrail ( array  $active_trail)

Sets the active trail IDs used to set the inActiveTrail property.

Parameters
string[]$active_trail An array containing the active trail: a list of menu link plugin IDs.
Returns
$this
See Also
::getActiveTrailIds()
setMaxDepth (   $max_depth)

Sets a maximum depth for menu tree loading.

Parameters
int$max_depthThe (root-relative) maximum depth to apply.
Returns
$this

Referenced by MenuTreeParameters\setTopLevelOnly().

Here is the caller graph for this function:

setMinDepth (   $min_depth)

Sets a minimum depth for menu tree loading.

Parameters
int$min_depthThe (root-relative) minimum depth to apply.
Returns
$this

Referenced by MenuTreeParameters\excludeRoot().

Here is the caller graph for this function:

setRoot (   $root)

Sets a root for menu tree loading.

Parameters
string$rootA menu link plugin ID, or empty string '' to use the root of the whole tree.
Returns
$this

References Drupal\root().

Here is the call graph for this function:

setTopLevelOnly ( )

Ensures only the top level of the tree is loaded.

Returns
$this

References MenuTreeParameters\setMaxDepth().

Here is the call graph for this function:


The documentation for this class was generated from the following file: