W3cubDocs

/Drupal 8

public function MenuTreeParameters::addCondition

public MenuTreeParameters::addCondition($definition_field, $value, $operator = NULL)

Adds a custom query condition.

Parameters

string $definition_field: Only conditions that are testing menu link definition fields are allowed.

mixed $value: The 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.

Return value

$this

File

core/lib/Drupal/Core/Menu/MenuTreeParameters.php, line 168

Class

MenuTreeParameters
Provides a value object to model menu tree parameters.

Namespace

Drupal\Core\Menu

Code

public function addCondition($definition_field, $value, $operator = NULL) {
  if (!isset($operator)) {
    $this->conditions[$definition_field] = $value;
  }
  else {
    $this->conditions[$definition_field] = array($value, $operator);
  }
  return $this;
}

© 2001–2016 by the original authors
Licensed under the GNU General Public License, version 2 and later.
Drupal is a registered trademark of Dries Buytaert.
https://api.drupal.org/api/drupal/core!lib!Drupal!Core!Menu!MenuTreeParameters.php/function/MenuTreeParameters::addCondition/8.1.x