None.php in Drupal 9
File
core/modules/views/src/Plugin/views/pager/None.php
View source
<?php
namespace Drupal\views\Plugin\views\pager;
use Drupal\Core\Form\FormStateInterface;
use Drupal\views\ViewExecutable;
use Drupal\views\Plugin\views\display\DisplayPluginBase;
class None extends PagerPluginBase {
public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
parent::init($view, $display, $options);
$this
->setItemsPerPage(0);
}
public function summaryTitle() {
if (!empty($this->options['offset'])) {
return $this
->t('All items, skip @skip', [
'@skip' => $this->options['offset'],
]);
}
return $this
->t('All items');
}
protected function defineOptions() {
$options = parent::defineOptions();
$options['offset'] = [
'default' => 0,
];
return $options;
}
public function buildOptionsForm(&$form, FormStateInterface $form_state) {
parent::buildOptionsForm($form, $form_state);
$form['offset'] = [
'#type' => 'number',
'#min' => 0,
'#title' => $this
->t('Offset (number of items to skip)'),
'#description' => $this
->t('For example, set this to 3 and the first 3 items will not be displayed.'),
'#default_value' => $this->options['offset'],
];
}
public function usePager() {
return FALSE;
}
public function useCountQuery() {
return FALSE;
}
public function getItemsPerPage() {
return 0;
}
public function executeCountQuery(&$count_query) {
}
public function postExecute(&$result) {
$this->total_items = count($result);
}
public function query() {
if (!empty($this->options['offset'])) {
$this->view->query
->setOffset($this->options['offset']);
}
}
}
Classes
Name |
Description |
None |
Plugin for views without pagers. |