Security update for Core, with self-updated composer
[yaffs-website] / web / core / modules / comment / src / Plugin / migrate / source / d6 / CommentVariablePerCommentType.php
1 <?php
2
3 namespace Drupal\comment\Plugin\migrate\source\d6;
4
5 @trigger_error('CommentVariablePerCommentType is deprecated in Drupal 8.4.x and will be removed before Drupal 9.0.x. Use \Drupal\node\Plugin\migrate\source\d6\NodeType instead.', E_USER_DEPRECATED);
6
7 /**
8  * @MigrateSource(
9  *   id = "d6_comment_variable_per_comment_type",
10  *   source_module = "comment"
11  * )
12  *
13  * @deprecated in Drupal 8.4.x, to be removed before Drupal 9.0.x. Use
14  * \Drupal\node\Plugin\migrate\source\d6\NodeType instead.
15  */
16 class CommentVariablePerCommentType extends CommentVariable {
17
18   /**
19    * Retrieves the values of the comment variables grouped by comment type.
20    *
21    * @return array
22    */
23   protected function getCommentVariables() {
24     $node_types = parent::getCommentVariables();
25     // The return key used to separate comment types with hidden subject field.
26     $return = [];
27     foreach ($node_types as $node_type => $data) {
28       // Only 2 comment types depending on subject field visibility.
29       if (!empty($data['comment_subject_field'])) {
30         // Default label and description should be set in migration.
31         $return['comment'] = [
32           'comment_type' => 'comment',
33           'label' => $this->t('Default comments'),
34           'description' => $this->t('Allows commenting on content')
35         ];
36       }
37       else {
38         // Provide a special comment type with hidden subject field.
39         $return['comment_no_subject'] = [
40           'comment_type' => 'comment_no_subject',
41           'label' => $this->t('Comments without subject field'),
42           'description' => $this->t('Allows commenting on content, comments without subject field')
43         ];
44       }
45     }
46     return $return;
47   }
48
49   /**
50    * {@inheritdoc}
51    */
52   public function fields() {
53     return [
54       'comment_type' => $this->t('The comment type'),
55       'label' => $this->t('The comment type label'),
56       'description' => $this->t('The comment type description'),
57     ];
58   }
59
60   /**
61    * {@inheritdoc}
62    */
63   public function getIds() {
64     $ids['comment_type']['type'] = 'string';
65     return $ids;
66   }
67
68 }