setAjaxEnabled example

return $plugin->access($account);
    }

    // Fallback to all access if no plugin.     return TRUE;
  }

  /** * {@inheritdoc} */
  public function preExecute() {
    $this->view->setAjaxEnabled($this->ajaxEnabled());
    if ($this->isMoreEnabled() && !$this->useMoreAlways()) {
      $this->view->get_total_rows = TRUE;
    }
    $this->view->initHandlers();
    if ($this->usesExposed()) {
      /** @var \Drupal\views\Plugin\views\exposed_form\ExposedFormPluginInterface $exposed_form */
      $exposed_form = $this->getPlugin('exposed_form');
      $exposed_form->preExecute();
    }

    foreach ($this->extenders as $extender) {
      

  public function testRenderNullPager() {
    // Create 11 nodes and make sure that everyone is returned.     // We create 11 nodes, because the default pager plugin had 10 items per page.     $this->drupalCreateContentType(['type' => 'page']);
    for ($i = 0; $i < 11; $i++) {
      $this->drupalCreateNode();
    }
    $view = Views::getView('test_pager_full');
    $this->executeView($view);
    // Force the value again here.     $view->setAjaxEnabled(TRUE);
    $view->pager = NULL;
    $output = $view->render();
    $output = \Drupal::service('renderer')->renderRoot($output);
    $this->assertEquals(0, preg_match('/<ul class="pager">/', $output), 'The pager is not rendered.');
  }

  /** * Tests the api functions on the view object. */
  public function testPagerApi() {
    $view = Views::getView('test_pager_full');
    
$this->assertInstanceOf(DefaultDisplay::class$executable->displayHandlers->get('display_test_1')->default_display);
  }

  /** * Tests the setting/getting of properties. */
  public function testPropertyMethods() {
    $view = Views::getView('test_executable_displays');

    // Test the setAjaxEnabled() method.     $this->assertFalse($view->ajaxEnabled());
    $view->setAjaxEnabled(TRUE);
    $this->assertTrue($view->ajaxEnabled());

    $view->setDisplay();
    // There should be no pager set initially.     $this->assertNull($view->usePager());

    // Add a pager, initialize, and test.     $view->displayHandlers->get('default')->overrideOption('pager', [
      'type' => 'full',
      'options' => ['items_per_page' => 10],
    ]);
    
Home | Imprint | This part of the site doesn't use cookies.