You are here

protected function WizardPluginBase::defaultDisplayOptions in Zircon Profile 8

Same name and namespace in other branches
  1. 8.0 core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php \Drupal\views\Plugin\views\wizard\WizardPluginBase::defaultDisplayOptions()

Assembles the default display options for the view.

Most wizards will need to override this method to provide some fields or a different row plugin.

Return value

array Returns an array of display options.

8 calls to WizardPluginBase::defaultDisplayOptions()
Comment::defaultDisplayOptions in core/modules/comment/src/Plugin/views/wizard/Comment.php
Assembles the default display options for the view.
File::defaultDisplayOptions in core/modules/file/src/Plugin/views/wizard/File.php
Assembles the default display options for the view.
Node::defaultDisplayOptions in core/modules/node/src/Plugin/views/wizard/Node.php
Assembles the default display options for the view.
NodeRevision::defaultDisplayOptions in core/modules/node/src/Plugin/views/wizard/NodeRevision.php
Assembles the default display options for the view.
TaxonomyTerm::defaultDisplayOptions in core/modules/taxonomy/src/Plugin/views/wizard/TaxonomyTerm.php
Assembles the default display options for the view.

... See full list

7 methods override WizardPluginBase::defaultDisplayOptions()
Comment::defaultDisplayOptions in core/modules/comment/src/Plugin/views/wizard/Comment.php
Assembles the default display options for the view.
File::defaultDisplayOptions in core/modules/file/src/Plugin/views/wizard/File.php
Assembles the default display options for the view.
Node::defaultDisplayOptions in core/modules/node/src/Plugin/views/wizard/Node.php
Assembles the default display options for the view.
NodeRevision::defaultDisplayOptions in core/modules/node/src/Plugin/views/wizard/NodeRevision.php
Assembles the default display options for the view.
TaxonomyTerm::defaultDisplayOptions in core/modules/taxonomy/src/Plugin/views/wizard/TaxonomyTerm.php
Assembles the default display options for the view.

... See full list

File

core/modules/views/src/Plugin/views/wizard/WizardPluginBase.php, line 797
Contains \Drupal\views\Plugin\views\wizard\WizardPluginBase.

Class

WizardPluginBase
Base class for Views wizard plugins.

Namespace

Drupal\views\Plugin\views\wizard

Code

protected function defaultDisplayOptions() {
  $display_options = array();
  $display_options['access']['type'] = 'none';
  $display_options['cache']['type'] = 'tag';
  $display_options['query']['type'] = 'views_query';
  $display_options['exposed_form']['type'] = 'basic';
  $display_options['pager']['type'] = 'full';
  $display_options['style']['type'] = 'default';
  $display_options['row']['type'] = 'fields';

  // Add default options array to each plugin type.
  foreach ($display_options as &$options) {
    $options['options'] = array();
  }

  // Add a least one field so the view validates and the user has a preview.
  // The base field can provide a default in its base settings; otherwise,
  // choose the first field with a field handler.
  $default_table = $this->base_table;
  $data = Views::viewsData()
    ->get($default_table);
  if (isset($data['table']['base']['defaults']['field'])) {
    $default_field = $data['table']['base']['defaults']['field'];

    // If the table for the default field is different to the base table,
    // load the view table data for this table.
    if (isset($data['table']['base']['defaults']['table']) && $data['table']['base']['defaults']['table'] != $default_table) {
      $default_table = $data['table']['base']['defaults']['table'];
      $data = Views::viewsData()
        ->get($default_table);
    }
  }
  else {
    foreach ($data as $default_field => $field_data) {
      if (isset($field_data['field']['id'])) {
        break;
      }
    }
  }

  // @todo Refactor the code to use ViewExecutable::addHandler. See
  //   https://www.drupal.org/node/2383157.
  $display_options['fields'][$default_field] = array(
    'table' => $default_table,
    'field' => $default_field,
    'id' => $default_field,
    'entity_type' => isset($data[$default_field]['entity type']) ? $data[$default_field]['entity type'] : NULL,
    'entity_field' => isset($data[$default_field]['entity field']) ? $data[$default_field]['entity field'] : NULL,
    'plugin_id' => $data[$default_field]['field']['id'],
  );
  return $display_options;
}