0eea68608cf3c4b82dbc317ffe875fc074ca9bb7
[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 /**
6  * @MigrateSource(
7  *   id = "d6_comment_variable_per_comment_type"
8  * )
9  */
10 class CommentVariablePerCommentType extends CommentVariable {
11
12   /**
13    * Retrieves the values of the comment variables grouped by comment type.
14    *
15    * @return array
16    */
17   protected function getCommentVariables() {
18     $node_types = parent::getCommentVariables();
19     // The return key used to separate comment types with hidden subject field.
20     $return = [];
21     foreach ($node_types as $node_type => $data) {
22       // Only 2 comment types depending on subject field visibility.
23       if (!empty($data['comment_subject_field'])) {
24         // Default label and description should be set in migration.
25         $return['comment'] = [
26           'comment_type' => 'comment',
27           'label' => $this->t('Default comments'),
28           'description' => $this->t('Allows commenting on content')
29         ];
30       }
31       else {
32         // Provide a special comment type with hidden subject field.
33         $return['comment_no_subject'] = [
34           'comment_type' => 'comment_no_subject',
35           'label' => $this->t('Comments without subject field'),
36           'description' => $this->t('Allows commenting on content, comments without subject field')
37         ];
38       }
39     }
40     return $return;
41   }
42
43   /**
44    * {@inheritdoc}
45    */
46   public function fields() {
47     return [
48       'comment_type' => $this->t('The comment type'),
49       'label' => $this->t('The comment type label'),
50       'description' => $this->t('The comment type description'),
51     ];
52   }
53
54   /**
55    * {@inheritdoc}
56    */
57   public function getIds() {
58     $ids['comment_type']['type'] = 'string';
59     return $ids;
60   }
61
62 }