class None

Same name in this branch
  1. 9 core/modules/views/src/Plugin/views/argument_validator/None.php \Drupal\views\Plugin\views\argument_validator\None
  2. 9 core/modules/views/src/Plugin/views/cache/None.php \Drupal\views\Plugin\views\cache\None
  3. 9 core/modules/views/src/Plugin/views/access/None.php \Drupal\views\Plugin\views\access\None
Same name and namespace in other branches
  1. 11.x core/modules/views/src/Plugin/views/argument_validator/None.php \Drupal\views\Plugin\views\argument_validator\None
  2. 11.x core/modules/views/src/Plugin/views/cache/None.php \Drupal\views\Plugin\views\cache\None
  3. 11.x core/modules/views/src/Plugin/views/access/None.php \Drupal\views\Plugin\views\access\None
  4. 11.x core/modules/views/src/Plugin/views/pager/None.php \Drupal\views\Plugin\views\pager\None

Plugin for views without pagers.

Plugin annotation


@ViewsPager(
  id = "none",
  title = @Translation("Display all items"),
  help = @Translation("Display all items that this view might find."),
  display_types = {"basic"}
)

Hierarchy

Expanded class hierarchy of None

Related topics

1 file declares its use of None
ViewExecutableTest.php in core/modules/views/tests/src/Unit/ViewExecutableTest.php
487 string references to 'None'
AccessRoleUITest::testAccessRoleUI in core/modules/user/tests/src/Functional/AccessRoleUITest.php
Tests the role access plugin UI.
AjaxTestController::getRenderTypes in core/modules/system/tests/modules/ajax_test/src/Controller/AjaxTestController.php
Render types.
AreaDisplayLinkTest::setUp in core/modules/views/tests/src/Kernel/Handler/AreaDisplayLinkTest.php
AreaDisplayLinkTest::testAreaDisplayLink in core/modules/views/tests/src/Kernel/Handler/AreaDisplayLinkTest.php
Tests the views area display_link handler.
AreaResultTest::testResultEmpty in core/modules/views/tests/src/Kernel/Handler/AreaResultTest.php
Tests the results area handler.

... See full list

File

core/modules/views/src/Plugin/views/pager/None.php, line 21

Namespace

Drupal\views\Plugin\views\pager
View source
class None extends PagerPluginBase {
  
  /**
   * {@inheritdoc}
   */
  public function init(ViewExecutable $view, DisplayPluginBase $display, array &$options = NULL) {
    parent::init($view, $display, $options);
    // If the pager is set to none, then it should show all items.
    $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;
  }
  
  /**
   * Provide the default form for setting 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) {
    // If we are displaying all items, never count. But we can update the count in post_execute.
  }
  public function postExecute(&$result) {
    $this->total_items = count($result);
  }
  public function query() {
    // The only query modifications we might do are offsets.
    if (!empty($this->options['offset'])) {
      $this->view->query
        ->setOffset($this->options['offset']);
    }
  }

}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.