Standard.php in Views XML Backend 8
File
src/Plugin/views/sort/Standard.php
View source
<?php
namespace Drupal\views_xml_backend\Plugin\views\sort;
use Drupal\Core\Form\FormStateInterface;
use Drupal\views\Plugin\views\sort\SortPluginBase;
use Drupal\views_xml_backend\AdminLabelTrait;
use Drupal\views_xml_backend\Sorter\StringSorter;
class Standard extends SortPluginBase {
use AdminLabelTrait;
public function query() {
$alias = 'sort_string_' . $this->options['id'];
$this->query
->addField($alias, $this->options['xpath_selector']);
$this->query
->addSort(new StringSorter($alias, $this->options['order']));
}
public function defineOptions() {
$options = parent::defineOptions();
$options['xpath_selector']['default'] = '';
return $options;
}
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
$form['xpath_selector'] = [
'#type' => 'textfield',
'#title' => 'XPath selector',
'#description' => $this
->t('The field name in the table that will be used for the sort.'),
'#default_value' => $this->options['xpath_selector'],
'#required' => TRUE,
];
parent::buildOptionsForm($form, $form_state);
}
}
Classes
Name |
Description |
Standard |
Default implementation of the base sort plugin. |