buildSort example

$this->build_info['fail'] = TRUE;
      return FALSE;
    }

    if ($this->style_plugin->usesFields()) {
      $this->_build('field');
    }

    // Build our sort criteria if we were instructed to do so.     if (!empty($this->build_sort)) {
      // Allow the style handler to deal with sorting.       if ($this->style_plugin->buildSort()) {
        $this->_build('sort');
      }
      // allow the plugin to build second sorts as well.       $this->style_plugin->buildSortPost();
    }

    // Allow area handlers to affect the query.     $this->_build('header');
    $this->_build('footer');
    $this->_build('empty');

    
$view->initHandlers();
    $view->initQuery();
    $style_plugin = $view->style_plugin;

    // Test the buildSort() method.     $request = new Request();
    $view->setRequest($request);

    $style_plugin->options['override'] = FALSE;

    $style_plugin->options['default'] = '';
    $this->assertTrue($style_plugin->buildSort(), 'If no order and no default order is specified, the normal sort should be used.');

    $style_plugin->options['default'] = 'id';
    $this->assertTrue($style_plugin->buildSort(), 'If no order but a default order is specified, the normal sort should be used.');

    $request->attributes->set('order', $this->randomMachineName());
    $this->assertTrue($style_plugin->buildSort(), 'If no valid field is chosen for order, the normal sort should be used.');

    $request->attributes->set('order', 'id');
    $this->assertTrue($style_plugin->buildSort(), 'If a valid order is specified but the table is configured to not override, the normal sort should be used.');

    $style_plugin->options['override'] = TRUE;

    
Home | Imprint | This part of the site doesn't use cookies.