public function ViewExecutable::newDisplay

Creates and stores a new display.

Parameters

string $id: The ID for the display being added.

Return value

Drupal\views\Plugin\views\display\DisplayPluginBase A reference to the new handler object.

File

drupal/core/modules/views/lib/Drupal/views/ViewExecutable.php, line 2244
Definition of Drupal\views\ViewExecutable.

Class

ViewExecutable
An object to contain all of the data to generate a view, plus the member functions to build the view query, execute the query and render the output.

Namespace

Drupal\views

Code

public function &newDisplay($id) {

  // Create a handler.
  $display = $this->storage
    ->get('display');
  $manager = drupal_container()
    ->get("plugin.manager.views.display");
  $this->displayHandlers[$id] = $manager
    ->createInstance($display[$id]['display_plugin']);
  if (empty($this->displayHandlers[$id])) {

    // provide a 'default' handler as an emergency. This won't work well but
    // it will keep things from crashing.
    $this->displayHandlers[$id] = $manager
      ->createInstance('default');
  }
  if (!empty($this->displayHandlers[$id])) {

    // Initialize the new display handler with data.
    $this->displayHandlers[$id]
      ->init($this, $display[$id]);

    // If this is NOT the default display handler, let it know which is
    if ($id != 'default') {

      // @todo is the '&' still required in php5?
      $this->displayHandlers[$id]->default_display =& $this->displayHandlers['default'];
    }
  }
  $this->storage
    ->set('display', $display);
  return $this->displayHandlers[$id];
}