You are here

function _support_ticket_comment_diff_field in Support Ticketing System 8

Determine comment field to write revision differences into.

Parameters

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

Return value

string $default The field name.

2 calls to _support_ticket_comment_diff_field()
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 793
Enables use of support tickets with optional time tracking.

Code

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