Adds the array of display options to the view, with appropriate overrides.
protected function addDisplays(View $view, $display_options, $form, $form_state) {
// Display: Master
$default_display = $view
->newDisplay('default', 'Master', 'default');
foreach ($display_options['default'] as $option => $value) {
$default_display
->setOption($option, $value);
}
// Display: Page
if (isset($display_options['page'])) {
$display = $view
->newDisplay('page', 'Page', 'page_1');
// The page display is usually the main one (from the user's point of
// view). Its options should therefore become the overall view defaults,
// so that new displays which are added later automatically inherit them.
$this
->setDefaultOptions($display_options['page'], $display, $default_display);
// Display: Feed (attached to the page).
if (isset($display_options['feed'])) {
$display = $view
->newDisplay('feed', 'Feed', 'feed_1');
$this
->set_override_options($display_options['feed'], $display, $default_display);
}
}
// Display: Block.
if (isset($display_options['block'])) {
$display = $view
->newDisplay('block', 'Block', 'block_1');
// When there is no page, the block display options should become the
// overall view defaults.
if (!isset($display_options['page'])) {
$this
->setDefaultOptions($display_options['block'], $display, $default_display);
}
else {
$this
->set_override_options($display_options['block'], $display, $default_display);
}
}
}