You are here

protected function Comment::defaultDisplayOptions in Drupal 9

Same name and namespace in other branches
  1. 8 core/modules/comment/src/Plugin/views/wizard/Comment.php \Drupal\comment\Plugin\views\wizard\Comment::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.

Overrides WizardPluginBase::defaultDisplayOptions

File

core/modules/comment/src/Plugin/views/wizard/Comment.php, line 57

Class

Comment
Tests creating comment views with the wizard.

Namespace

Drupal\comment\Plugin\views\wizard

Code

protected function defaultDisplayOptions() {
  $display_options = parent::defaultDisplayOptions();

  // Add permission-based access control.
  $display_options['access']['type'] = 'perm';
  $display_options['access']['options']['perm'] = 'access comments';

  // Add a relationship to nodes.
  $display_options['relationships']['node']['id'] = 'node';
  $display_options['relationships']['node']['table'] = 'comment_field_data';
  $display_options['relationships']['node']['field'] = 'node';
  $display_options['relationships']['node']['entity_type'] = 'comment_field_data';
  $display_options['relationships']['node']['required'] = 1;
  $display_options['relationships']['node']['plugin_id'] = 'standard';

  // Remove the default fields, since we are customizing them here.
  unset($display_options['fields']);

  /* Field: Comment: Title */
  $display_options['fields']['subject']['id'] = 'subject';
  $display_options['fields']['subject']['table'] = 'comment_field_data';
  $display_options['fields']['subject']['field'] = 'subject';
  $display_options['fields']['subject']['entity_type'] = 'comment';
  $display_options['fields']['subject']['entity_field'] = 'subject';
  $display_options['fields']['subject']['label'] = '';
  $display_options['fields']['subject']['alter']['alter_text'] = 0;
  $display_options['fields']['subject']['alter']['make_link'] = 0;
  $display_options['fields']['subject']['alter']['absolute'] = 0;
  $display_options['fields']['subject']['alter']['trim'] = 0;
  $display_options['fields']['subject']['alter']['word_boundary'] = 0;
  $display_options['fields']['subject']['alter']['ellipsis'] = 0;
  $display_options['fields']['subject']['alter']['strip_tags'] = 0;
  $display_options['fields']['subject']['alter']['html'] = 0;
  $display_options['fields']['subject']['hide_empty'] = 0;
  $display_options['fields']['subject']['empty_zero'] = 0;
  $display_options['fields']['subject']['plugin_id'] = 'field';
  $display_options['fields']['subject']['type'] = 'string';
  $display_options['fields']['subject']['settings'] = [
    'link_to_entity' => TRUE,
  ];
  return $display_options;
}