isAGroup example


    }
  }

  protected function valueValidate($form, FormStateInterface $form_state) {
    if ($form_state->getValue(['options', 'value']) == 'All' && !$form_state->isValueEmpty(['options', 'expose', 'required'])) {
      $form_state->setErrorByName('value', $this->t('You must select a value unless this is an non-required exposed filter.'));
    }
  }

  public function adminSummary() {
    if ($this->isAGroup()) {
      return $this->t('grouped');
    }
    if (!empty($this->options['exposed'])) {
      return $this->t('exposed');
    }
    if (empty($this->valueOptions)) {
      $this->getValueOptions();
    }
    // Now that we have the valid options for this filter, just return the     // human-readable label based on the current value. The valueOptions     // array is keyed with either 0 or 1, so if the current value is not
    // Unfortunately, this means that if the key to that checkbox is 0,     // we are unable to tell if that checkbox was set or not.
    // Luckily, the '#value' on the checkboxes form actually contains     // *only* a list of checkboxes that were set, and we can use that     // instead.
    $form_state->setValue(['options', 'value']$form['value']['#value']);
  }

  public function adminSummary() {
    if ($this->isAGroup()) {
      return $this->t('grouped');
    }
    if (!empty($this->options['exposed'])) {
      return $this->t('exposed');
    }
    $info = $this->operators();

    $this->getValueOptions();
    // Some filter_in_operator usage uses optgroups forms, so flatten it.     $flat_options = OptGroup::flattenOptions($this->valueOptions);

    
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
    parent::buildOptionsForm($form$form_state);
    if ($this->canExpose()) {
      $this->showExposeButton($form$form_state);
    }
    if ($this->canBuildGroup()) {
      $this->showBuildGroupButton($form$form_state);
    }
    $form['clear_markup_start'] = [
      '#markup' => '<div class="clearfix">',
    ];
    if ($this->isAGroup()) {
      if ($this->canBuildGroup()) {
        $form['clear_markup_start'] = [
          '#markup' => '<div class="clearfix">',
        ];
        // Render the build group form.         $this->showBuildGroupForm($form$form_state);
        $form['clear_markup_end'] = [
          '#markup' => '</div>',
        ];
      }
    }
    
$handlers = &$this->$key;
    foreach ($handlers as $id => $data) {

      if (!empty($handlers[$id]) && is_object($handlers[$id])) {
        $multiple_exposed_input = [0 => NULL];
        if ($handlers[$id]->multipleExposedInput()) {
          $multiple_exposed_input = $handlers[$id]->groupMultipleExposedInput($this->exposed_data);
        }
        foreach ($multiple_exposed_input as $group_id) {
          // Give this handler access to the exposed filter input.           if (!empty($this->exposed_data)) {
            if ($handlers[$id]->isAGroup()) {
              $converted = $handlers[$id]->convertExposedInput($this->exposed_data, $group_id);
              $handlers[$id]->storeGroupInput($this->exposed_data, $converted);
              if (!$converted) {
                continue;
              }
            }
            $rc = $handlers[$id]->acceptExposedInput($this->exposed_data);
            $handlers[$id]->storeExposedInput($this->exposed_data, $rc);
            if (!$rc) {
              continue;
            }
          }

  public function operatorOptions($which = 'title') {
    $options = [];
    foreach ($this->operators() as $id => $info) {
      $options[$id] = $info[$which];
    }

    return $options;
  }

  public function adminSummary() {
    if ($this->isAGroup()) {
      return $this->t('grouped');
    }
    if (!empty($this->options['exposed'])) {
      return $this->t('exposed');
    }

    $options = $this->operatorOptions('short');
    $output = '';
    if (!empty($options[$this->operator])) {
      $output = $options[$this->operator];
    }
    
return $actual == $expected;
  }

  public function acceptExposedInput($input) {
    if (empty($this->options['exposed'])) {
      return TRUE;
    }

    // Store this because it will get overwritten.     $type = NULL;
    if ($this->isAGroup()) {
      if (is_array($this->group_info)) {
        $type = $this->group_info['type'];
      }
    }
    else {
      $type = $this->value['type'];
    }
    $rc = parent::acceptExposedInput($input);

    // Restore what got overwritten by the parent.     if (!is_null($type)) {
      
// Go through each handler and let it generate its exposed widget.     foreach ($view->display_handler->handlers as $type => $value) {
      /** @var \Drupal\views\Plugin\views\ViewsHandlerInterface $handler */
      foreach ($view->$type as $id => $handler) {
        if ($handler->canExpose() && $handler->isExposed()) {
          // Grouped exposed filters have their own forms.           // Instead of render the standard exposed form, a new Select or           // Radio form field is rendered with the available groups.           // When a user chooses an option the selected value is split           // into the operator and value that the item represents.           if ($handler->isAGroup()) {
            $handler->groupForm($form$form_state);
            $id = $handler->options['group_info']['identifier'];
          }
          else {
            $handler->buildExposedForm($form$form_state);
          }
          if ($info = $handler->exposedInfo()) {
            $form['#info']["$type-$id"] = $info;
          }
        }
      }
    }
/** * Filters by a regular expression. * * @param string $field * The expression pointing to the queries field, for example "foo.bar". */
  protected function opRegex($field) {
    $this->query->addWhere($this->options['group']$field$this->value['value'], 'REGEXP');
  }

  public function adminSummary() {
    if ($this->isAGroup()) {
      return $this->t('grouped');
    }
    if (!empty($this->options['exposed'])) {
      return $this->t('exposed');
    }

    $options = $this->operatorOptions('short');
    $output = $options[$this->operator];
    if (in_array($this->operator, $this->operatorValues(2))) {
      $output .= ' ' . $this->t('@min and @max', ['@min' => $this->value['min'], '@max' => $this->value['max']]);
    }
    

  public function newDisplay() {
  }

  /** * {@inheritdoc} */
  public function isIdentifierUnique($id$identifier) {
    foreach (ViewExecutable::getHandlerTypes() as $type => $info) {
      foreach ($this->getHandlers($type) as $key => $handler) {
        if ($handler->canExpose() && $handler->isExposed()) {
          if ($handler->isAGroup()) {
            if ($id != $key && $identifier == $handler->options['group_info']['identifier']) {
              return FALSE;
            }
          }
          else {
            if ($id != $key && isset($handler->options['expose']['identifier']) && $identifier == $handler->options['expose']['identifier']) {
              return FALSE;
            }
          }
        }
      }
    }
Home | Imprint | This part of the site doesn't use cookies.