You are here

function comment_notify_entity_extra_field_info in Comment Notify 8

Implements hook_field_extra_fields().

File

./comment_notify.module, line 567
This module provides comment follow-up e-mail notifications.

Code

function comment_notify_entity_extra_field_info() {
  module_load_include('inc', 'comment_notify', 'comment_notify');
  $extras = [];
  $config = \Drupal::config('comment_notify.settings');
  foreach ($config
    ->get('bundle_types') as $bundle_type) {
    $field_identifier = explode('--', $bundle_type);
    $comment_field = FieldConfig::loadByName($field_identifier[0], $field_identifier[1], $field_identifier[2]);
    if ($comment_field) {
      $bundle_info = \Drupal::service("entity_type.bundle.info")
        ->getBundleInfo($field_identifier[0]);
      $bundle_label = $bundle_info[$field_identifier[1]]['label'];
      $comment_type = $comment_field
        ->getSetting('comment_type');
      $extras['comment'][$comment_type]['form']['comment_notify_settings'] = [
        'label' => t('Comment Notify settings'),
        'description' => t('@bundle_type settings for Comment Notify', [
          '@bundle_type' => $bundle_label,
        ]),
        'weight' => 1,
      ];
    }
  }
  $extras['user']['user']['form']['comment_notify_settings'] = [
    'label' => t('Comment Notify settings'),
    'description' => t('User settings for Comment Notify'),
    'weight' => 4,
  ];
  return $extras;
}