3 namespace Drupal\views\Plugin\views\pager;
5 use Drupal\Core\Form\FormStateInterface;
6 use Drupal\views\ViewExecutable;
7 use Drupal\views\Plugin\views\display\DisplayPluginBase;
10 * Plugin for views without pagers.
12 * @ingroup views_pager_plugins
16 * title = @Translation("Display all items"),
17 * help = @Translation("Display all items that this view might find."),
18 * display_types = {"basic"}
21 class None extends PagerPluginBase {
26 public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
27 parent::init($view, $display, $options);
29 // If the pager is set to none, then it should show all items.
30 $this->setItemsPerPage(0);
33 public function summaryTitle() {
34 if (!empty($this->options['offset'])) {
35 return $this->t('All items, skip @skip', ['@skip' => $this->options['offset']]);
37 return $this->t('All items');
40 protected function defineOptions() {
41 $options = parent::defineOptions();
42 $options['offset'] = ['default' => 0];
48 * Provide the default form for setting options.
50 public function buildOptionsForm(&$form, FormStateInterface $form_state) {
51 parent::buildOptionsForm($form, $form_state);
53 '#type' => 'textfield',
54 '#title' => $this->t('Offset (number of items to skip)'),
55 '#description' => $this->t('For example, set this to 3 and the first 3 items will not be displayed.'),
56 '#default_value' => $this->options['offset'],
60 public function usePager() {
64 public function useCountQuery() {
68 public function getItemsPerPage() {
72 public function executeCountQuery(&$count_query) {
73 // If we are displaying all items, never count. But we can update the count in post_execute.
76 public function postExecute(&$result) {
77 $this->total_items = count($result);
80 public function query() {
81 // The only query modifications we might do are offsets.
82 if (!empty($this->options['offset'])) {
83 $this->view->query->setOffset($this->options['offset']);