Sets the current display.
string $display_id: The ID of the display to mark as current.
bool TRUE if the display was correctly set, FALSE otherwise.
public function setDisplay($display_id = NULL) {
// If we have not already initialized the display, do so.
if (!isset($this->current_display)) {
// This will set the default display and instantiate the default display
// plugin.
$this
->initDisplay();
}
// If no display ID is passed, we either have initialized the default or
// already have a display set.
if (!isset($display_id)) {
return TRUE;
}
$display_id = $this
->chooseDisplay($display_id);
// Ensure the requested display exists.
if (!$this->displayHandlers
->has($display_id)) {
debug(format_string('setDisplay() called with invalid display ID "@display".', array(
'@display' => $display_id,
)));
return FALSE;
}
// Reset if the display has changed. It could be called multiple times for
// the same display, especially in the UI.
if ($this->current_display != $display_id) {
// Set the current display.
$this->current_display = $display_id;
// Reset the style and row plugins.
$this->style_plugin = NULL;
$this->plugin_name = NULL;
$this->rowPlugin = NULL;
}
if ($display = $this->displayHandlers
->get($display_id)) {
// Set a shortcut.
$this->display_handler = $display;
return TRUE;
}
return FALSE;
}