Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / comment / src / Plugin / views / wizard / Comment.php
1 <?php
2
3 namespace Drupal\comment\Plugin\views\wizard;
4
5 use Drupal\views\Plugin\views\wizard\WizardPluginBase;
6
7 /**
8  * @todo: replace numbers with constants.
9  */
10
11 /**
12  * Tests creating comment views with the wizard.
13  *
14  * @ViewsWizard(
15  *   id = "comment",
16  *   base_table = "comment_field_data",
17  *   title = @Translation("Comments")
18  * )
19  */
20 class Comment extends WizardPluginBase {
21
22   /**
23    * Set the created column.
24    *
25    * @var string
26    */
27   protected $createdColumn = 'created';
28
29   /**
30    * Set default values for the filters.
31    */
32   protected $filters = [
33     'status' => [
34       'value' => TRUE,
35       'table' => 'comment_field_data',
36       'field' => 'status',
37       'plugin_id' => 'boolean',
38       'entity_type' => 'comment',
39       'entity_field' => 'status',
40     ],
41     'status_node' => [
42       'value' => TRUE,
43       'table' => 'node_field_data',
44       'field' => 'status',
45       'plugin_id' => 'boolean',
46       'relationship' => 'node',
47       'entity_type' => 'node',
48       'entity_field' => 'status',
49     ],
50   ];
51
52   /**
53    * {@inheritdoc}
54    */
55   protected function rowStyleOptions() {
56     $options = [];
57     $options['entity:comment'] = $this->t('comments');
58     $options['fields'] = $this->t('fields');
59     return $options;
60   }
61
62   /**
63    * {@inheritdoc}
64    */
65   protected function defaultDisplayOptions() {
66     $display_options = parent::defaultDisplayOptions();
67
68     // Add permission-based access control.
69     $display_options['access']['type'] = 'perm';
70     $display_options['access']['options']['perm'] = 'access comments';
71
72     // Add a relationship to nodes.
73     $display_options['relationships']['node']['id'] = 'node';
74     $display_options['relationships']['node']['table'] = 'comment_field_data';
75     $display_options['relationships']['node']['field'] = 'node';
76     $display_options['relationships']['node']['entity_type'] = 'comment_field_data';
77     $display_options['relationships']['node']['required'] = 1;
78     $display_options['relationships']['node']['plugin_id'] = 'standard';
79
80     // Remove the default fields, since we are customizing them here.
81     unset($display_options['fields']);
82
83     /* Field: Comment: Title */
84     $display_options['fields']['subject']['id'] = 'subject';
85     $display_options['fields']['subject']['table'] = 'comment_field_data';
86     $display_options['fields']['subject']['field'] = 'subject';
87     $display_options['fields']['subject']['entity_type'] = 'comment';
88     $display_options['fields']['subject']['entity_field'] = 'subject';
89     $display_options['fields']['subject']['label'] = '';
90     $display_options['fields']['subject']['alter']['alter_text'] = 0;
91     $display_options['fields']['subject']['alter']['make_link'] = 0;
92     $display_options['fields']['subject']['alter']['absolute'] = 0;
93     $display_options['fields']['subject']['alter']['trim'] = 0;
94     $display_options['fields']['subject']['alter']['word_boundary'] = 0;
95     $display_options['fields']['subject']['alter']['ellipsis'] = 0;
96     $display_options['fields']['subject']['alter']['strip_tags'] = 0;
97     $display_options['fields']['subject']['alter']['html'] = 0;
98     $display_options['fields']['subject']['hide_empty'] = 0;
99     $display_options['fields']['subject']['empty_zero'] = 0;
100     $display_options['fields']['subject']['plugin_id'] = 'field';
101     $display_options['fields']['subject']['type'] = 'string';
102     $display_options['fields']['subject']['settings'] = ['link_to_entity' => TRUE];
103
104     return $display_options;
105   }
106
107 }