You are here

function _support_ticket_comment_diff_revision_changes in Support Ticketing System 8

Determine text comment field to write revision changes into.

Parameters

\Drupal\support_ticket\SupportTicketTypeInterface $entity_type: The support ticket entity type.

string $comment_type: The comment type.

Return value

string $default The field name.

2 calls to _support_ticket_comment_diff_revision_changes()
support_ticket_entity_update in modules/support_ticket/support_ticket.module
Implements hook_entity_update().
support_ticket_form_support_ticket_type_edit_form_alter in modules/support_ticket/support_ticket.module
Implements hook_form_BASE_FORM_ID_alter().

File

modules/support_ticket/support_ticket.module, line 853
Enables use of support tickets with optional time tracking.

Code

function _support_ticket_comment_diff_revision_changes($entity_type, $comment_type) {
  $config = \Drupal::configFactory()
    ->get('support_ticket.settings');
  $default = $config
    ->get('support_ticket_type_settings.' . $entity_type . '.comment_diff_revision_changes');
  if ($default === NULL) {
    $fields = \Drupal::entityManager()
      ->getFieldDefinitions('comment', $comment_type);
    foreach ($fields as $field) {
      if ($field
        ->getType() == 'text_long' && ($field_name = $field
        ->getName()) != 'comment_body') {
        $default = $field_name;
        \Drupal::configFactory()
          ->getEditable('support_ticket.settings')
          ->set('support_ticket_type_settings.' . $entity_type . '.comment_diff_revision_changes', $default)
          ->save();
        break;
      }
    }
  }
  return $default;
}