You are here

function menu_references_filter_handler::query in Menu Reference 7

Add this filter to the query.

Due to the nature of fapi, the value and the operator have an unintended level of indirection. You will find them in $this->operator and $this->value respectively.

Overrides views_handler_filter_in_operator::query

File

views/handlers/menu_references_filter_handler.inc, line 147
Views filter handler

Class

menu_references_filter_handler
@file Views filter handler

Code

function query() {
  $this->value = isset($this->value['value']) ? array(
    $this->value['value'],
  ) : $this->value;

  // Get all the subchild mlids if option is set.
  if (!empty($this->options['include_childrens'])) {

    // Get the menues.
    $field_settings = field_info_field($this->definition['field_name']);
    $allowed_menus = array_filter($field_settings['settings']['allowed_menus']);
    foreach ($allowed_menus as $machine_name) {
      $tmp_values = array();
      foreach ($this->value as $value) {
        $childs = menu_reference_get_all_menu_children($value, $machine_name);
        $tmp_values = array_merge($tmp_values, $childs);
      }
      $this->value = array_merge($this->value, $tmp_values);
    }

    // Remove duplicate mlids.
    $this->value = array_unique($this->value);
  }
  $info = $this
    ->operators();
  if (!empty($info[$this->operator]['method'])) {
    $this
      ->{$info[$this->operator]['method']}();
  }
}