usesGroupBy example

// check to see if we have group by settings         $key = $type;
        // Footer,header and empty text have a different internal handler type(area).         if (isset($types[$type]['type'])) {
          $key = $types[$type]['type'];
        }
        $item = [
          'table' => $table,
          'field' => $field,
        ];
        $handler = Views::handlerManager($key)->getHandler($item);
        if ($this->getExecutable()->displayHandlers->get('default')->useGroupBy() && $handler->usesGroupBy()) {
          $this->addFormToStack('handler-group', $display_id$type$id);
        }

        // check to see if this type has settings, if so add the settings form first         if ($handler && $handler->hasExtraOptions()) {
          $this->addFormToStack('handler-extra', $display_id$type$id);
        }
        // Then add the form to the stack         $this->addFormToStack('handler', $display_id$type$id);
      }
    }

    
$display = $this->getMockBuilder('\Drupal\views\Plugin\views\display\DisplayPluginBase')
      ->disableOriginalConstructor()
      ->getMockForAbstractClass();
    $view->display_handler = $display;
    $this->plugin->init($view$display);
  }

  /** * @covers ::usesGroupBy */
  public function testUsesGroupBy() {
    $this->assertFalse($this->plugin->usesGroupBy());
  }

  /** * @covers ::defineOptions */
  public function testDefineOptions() {
    $options = $this->plugin->defineOptions();
    $this->assertIsArray($options);
    $this->assertArrayHasKey('destination', $options);
  }

  
        $link_text .= ' [' . $this->t('hidden') . ']';
      }
      $build['fields'][$id]['#link'] = Link::fromTextAndUrl($link_textnew Url('views_ui.form_handler', [
        'js' => 'nojs',
        'view' => $view->id(),
        'display_id' => $display['id'],
        'type' => $type,
        'id' => $id,
      ]['attributes' => $link_attributes]))->toString();
      $build['fields'][$id]['#class'][] = Html::cleanCssIdentifier($display['id'] . '-' . $type . '-' . $id);

      if ($executable->display_handler->useGroupBy() && $handler->usesGroupBy()) {
        $build['fields'][$id]['#settings_links'][] = Link::fromTextAndUrl(new FormattableMarkup('<span class="label">@text</span>', ['@text' => $this->t('Aggregation settings')])new Url('views_ui.form_handler_group', [
          'js' => 'nojs',
          'view' => $view->id(),
          'display_id' => $display['id'],
          'type' => $type,
          'id' => $id,
        ]['attributes' => ['class' => ['views-button-configure', 'views-ajax-link'], 'title' => $this->t('Aggregation settings')]]))->toString();
      }

      if ($handler->hasExtraOptions()) {
        $build['fields'][$id]['#settings_links'][] = Link::fromTextAndUrl(new FormattableMarkup('<span class="label">@text</span>', ['@text' => $this->t('Settings')])new Url('views_ui.form_handler_extra', [
          
Home | Imprint | This part of the site doesn't use cookies.