Commit bb1fa1f9 authored by dawehner's avatar dawehner Committed by tim.plunkett

Issue #1802930 by dawehner: Introduce an isEnabled() method for display plugins.

parent dc2f17e3
......@@ -247,6 +247,16 @@ public function isAJAXEnabled() {
return FALSE;
}
/**
* Whether the display is enabled.
*
* @return bool
* Returns TRUE if the display is marked as enabled, else FALSE.
*/
public function isEnabled() {
return (bool) $this->getOption('enabled');
}
/**
* Whether the display allows the use of a pager or not.
*
......
......@@ -98,6 +98,12 @@ function testDisplayPlugin() {
// Check the new value has been saved by checking the UI summary text.
$this->drupalGet('admin/structure/views/view/frontpage/edit/display_test_1');
$this->assertRaw($this->randomString);
// Test the enable/disable status of a display.
$view->display_handler->setOption('enabled', FALSE);
$this->assertFalse($view->display_handler->isEnabled(), 'Make sure that isEnabled returns FALSE on a disabled display.');
$view->display_handler->setOption('enabled', TRUE);
$this->assertTrue($view->display_handler->isEnabled(), 'Make sure that isEnabled returns TRUE on a disabled display.');
}
/**
......
......@@ -1169,7 +1169,7 @@ public function execute($display_id = NULL) {
}
// Don't allow to use deactivated displays, but display them on the live preview.
if (!$this->display_handler->getOption('enabled') && empty($this->live_preview)) {
if (!$this->display_handler->isEnabled() && empty($this->live_preview)) {
$this->build_info['fail'] = TRUE;
return FALSE;
}
......
......@@ -1561,7 +1561,7 @@ function views_get_applicable_views($type) {
// This view uses_hook_menu. Clone it so that different handlers
// don't trip over each other, and add it to the list.
$v = $executable->cloneView();
if ($v->setDisplay($id) && $v->display_handler->getOption('enabled')) {
if ($v->setDisplay($id) && $v->display_handler->isEnabled()) {
$result[] = array($v, $id);
}
// In PHP 4.4.7 and presumably earlier, if we do not unset $v
......
......@@ -171,7 +171,7 @@ public function getDisplayDetails($display) {
// The master display cannot be cloned.
$is_default = $display['id'] == 'default';
// @todo: Figure out why getOption doesn't work here.
$is_enabled = $this->displayHandlers[$display['id']]->getOption('enabled');
$is_enabled = $this->displayHandlers[$display['id']]->isEnabled();
if ($display['id'] != 'default') {
$build['top']['#theme_wrappers'] = array('container');
......@@ -1376,8 +1376,7 @@ public function buildEditForm($form, &$form_state, $display_id = NULL) {
// Add a text that the display is disabled.
if (!empty($this->displayHandlers[$display_id])) {
$enabled = $this->displayHandlers[$display_id]->getOption('enabled');
if (empty($enabled)) {
if ($this->displayHandlers[$display_id]->isEnabled()) {
$form['displays']['settings']['disabled']['#markup'] = t('This display is disabled.');
}
}
......
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