function MenuTreeParameters::addCondition

Same name in other branches
  1. 8.9.x core/lib/Drupal/Core/Menu/MenuTreeParameters.php \Drupal\Core\Menu\MenuTreeParameters::addCondition()
  2. 10 core/lib/Drupal/Core/Menu/MenuTreeParameters.php \Drupal\Core\Menu\MenuTreeParameters::addCondition()
  3. 11.x core/lib/Drupal/Core/Menu/MenuTreeParameters.php \Drupal\Core\Menu\MenuTreeParameters::addCondition()

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

1 call to MenuTreeParameters::addCondition()
MenuTreeParameters::onlyEnabledLinks in core/lib/Drupal/Core/Menu/MenuTreeParameters.php
Excludes links that are not enabled.

File

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

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] = [
            $value,
            $operator,
        ];
    }
    return $this;
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.