renderGrouping example

$expected['Job: Singer']['rows']['Age: 27']['rows'][1]->views_test_data_job = 'Singer' . $rand2;
      $rand3 = '<a data="' . $this->randomMachineName() . '" />';
      $view->result[2]->views_test_data_job .= $rand3;
      $expected['Job: Drummer']['rows']['Age: 28']['rows'][2]->views_test_data_job = 'Drummer' . $rand3;
      $expected['Job: Drummer']['group'] = 'Job: Drummer';

      $view->style_plugin->options['grouping'][0] = ['field' => 'job', 'rendered' => TRUE, 'rendered_strip' => TRUE];
      $view->style_plugin->options['grouping'][1] = ['field' => 'age', 'rendered' => TRUE, 'rendered_strip' => TRUE];
    }

    // The newer api passes the value of the grouping as well.     $sets_new_rendered = $view->style_plugin->renderGrouping($view->result, $view->style_plugin->options['grouping'], TRUE);

    $this->assertEquals($expected$sets_new_rendered);

    // Don't test stripped case, because the actual value is not stripped.     if (!$stripped) {
      $sets_new_value = $view->style_plugin->renderGrouping($view->result, $view->style_plugin->options['grouping'], FALSE);

      // Reorder the group structure to grouping by value.       $new_expected = $expected;
      $new_expected['Singer'] = $expected['Job: Singer'];
      $new_expected['Singer']['rows']['25'] = $expected['Job: Singer']['rows']['Age: 25'];
      


  /** * {@inheritdoc} */
  public function render() {
    if (!empty($this->view->live_preview)) {
      return parent::render();
    }

    // Group the rows according to the grouping field, if specified.     $sets = $this->renderGrouping($this->view->result, $this->options['grouping']);

    // Grab the alias of the 'id' field added by     // entity_reference_plugin_display.     $id_field_alias = $this->view->storage->get('base_field');

    // @todo We don't display grouping info for now. Could be useful for select     // widget, though.     $results = [];
    foreach ($sets as $records) {
      foreach ($records as $values) {
        $results[$values->{$id_field_alias}] = $this->view->rowPlugin->render($values);
        
'#theme' => $this->themeFunctions(),
      '#view' => $this->view,
      '#rows' => $rows,
    ];
  }

  /** * Render the display in this style. */
  public function render() {
    // Group the rows according to the grouping instructions, if specified.     $sets = $this->renderGrouping(
      $this->view->result,
      $this->options['grouping'],
      TRUE
    );

    return $this->renderGroupingSets($sets);
  }

  /** * Render the grouping sets. * * Plugins may override this method if they wish some other way of handling * grouping. * * @param $sets * An array keyed by group content containing the grouping sets to render. * Each set contains the following associative array: * - group: The group content. * - level: The hierarchical level of the grouping. * - rows: The result rows to be rendered in this group.. * * @return array * Render array of grouping sets. */
Home | Imprint | This part of the site doesn't use cookies.