Commit 26253b37 authored by catch's avatar catch

Issue #1866910 by damiankloip: Add an ajaxEnabled() method for ViewExecutable.

parent c962f4f5
......@@ -176,7 +176,7 @@ public function submitOptionsForm(&$form, &$form_state) {
* Block views use exposed widgets only if AJAX is set.
*/
public function usesExposed() {
if ($this->isAJAXEnabled()) {
if ($this->ajaxEnabled()) {
return parent::usesExposed();
}
return FALSE;
......
......@@ -244,7 +244,7 @@ public function usesAJAX() {
*
* @return bool
*/
public function isAJAXEnabled() {
public function ajaxEnabled() {
if ($this->usesAJAX()) {
return $this->getOption('use_ajax');
}
......@@ -2488,7 +2488,7 @@ public function access($account = NULL) {
* overridden on an individual display.
*/
public function preExecute() {
$this->view->setUseAJAX($this->isAJAXEnabled());
$this->view->setAjaxEnabled($this->ajaxEnabled());
if ($this->usesMore() && !$this->useMoreAlways()) {
$this->view->get_total_rows = TRUE;
}
......
......@@ -33,7 +33,7 @@ class Feed extends PathPluginBase {
*
* @var bool
*/
protected $usesAJAX = FALSE;
protected $ajaxEnabled = FALSE;
/**
* Whether the display allows the use of a pager or not.
......
......@@ -250,7 +250,8 @@ public function testRenderNullPager() {
}
$view = views_get_view('test_pager_full');
$this->executeView($view);
$view->use_ajax = TRUE; // force the value again here
// Force the value again here.
$view->setAjaxEnabled(TRUE);
$view->pager = NULL;
$output = $view->render();
$output = drupal_render($output);
......
......@@ -57,7 +57,6 @@ class ViewExecutableTest extends ViewUnitTestBase {
'executed',
'args',
'build_info',
'use_ajax',
'result',
'attachment_before',
'attachment_after',
......@@ -201,10 +200,10 @@ public function testDisplays() {
public function testPropertyMethods() {
$view = views_get_view('test_executable_displays');
// Test the setUseAJAX() method.
$this->assertFalse($view->use_ajax);
$view->setUseAJAX(TRUE);
$this->assertTrue($view->use_ajax);
// Test the setAjaxEnabled() method.
$this->assertFalse($view->ajaxEnabled());
$view->setAjaxEnabled(TRUE);
$this->assertTrue($view->ajaxEnabled());
$view->setDisplay();
// There should be no pager set initially.
......
......@@ -67,7 +67,7 @@ class ViewExecutable {
*
* @var bool
*/
public $use_ajax = FALSE;
protected $ajaxEnabled = FALSE;
/**
* Where the results of a query will go.
......@@ -533,12 +533,27 @@ public function usePager() {
}
/**
* Whether or not AJAX should be used. If AJAX is used, paging,
* tablesorting and exposed filters will be fetched via an AJAX call
* rather than a page refresh.
* Sets whether or not AJAX should be used.
*
* If AJAX is used, paging, tablesorting and exposed filters will be fetched
* via an AJAX call rather than a page refresh.
*
* @param bool $use_ajax
* TRUE if AJAX should be used, FALSE otherwise.
*/
public function setAjaxEnabled($ajax_enabled) {
$this->ajaxEnabled = (bool) $ajax_enabled;
}
/**
* Whether or not AJAX should be used.
*
* @see \Drupal\views\ViewExecutable::setAjaxEnabled().
*
* @return bool
*/
public function setUseAJAX($use_ajax) {
$this->use_ajax = $use_ajax;
public function ajaxEnabled() {
return $this->ajaxEnabled;
}
/**
......
......@@ -130,7 +130,7 @@ function template_preprocess_views_view(&$vars) {
}
// If using AJAX, send identifying data about this view.
if ($view->use_ajax && empty($view->is_attachment) && empty($view->live_preview)) {
if ($view->ajaxEnabled() && empty($view->is_attachment) && empty($view->live_preview)) {
$settings = array(
'views' => array(
'ajax_path' => url('views/ajax'),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment