You are here

protected function SupportTicketRevisionController::buildTableHeader in Support Ticketing System 8

Build the header for the diff table.

Parameters

$left_revision: Revision from the left hand side.

$right_revision: Revision from the right hand side.

Return value

array Header for Diff table.

1 call to SupportTicketRevisionController::buildTableHeader()
SupportTicketRevisionController::compareSupportTicketRevisions in modules/support_ticket/src/Controller/SupportTicketRevisionController.php
Returns a table which shows the differences between two support ticket revisions.

File

modules/support_ticket/src/Controller/SupportTicketRevisionController.php, line 171
Contains \Drupal\support_ticket\Controller\SupportTicketRevisionController.

Class

SupportTicketRevisionController
Returns responses for Support Ticket Revision routes.

Namespace

Drupal\support_ticket\Controller

Code

protected function buildTableHeader($left_revision, $right_revision) {
  $revisions = array(
    $left_revision,
    $right_revision,
  );
  $header = array();
  foreach ($revisions as $revision) {
    $revision_log = $this->nonBreakingSpace;
    if ($revision->revision_log->value != '') {
      $revision_log = Xss::filter($revision->revision_log->value);
    }
    $username = array(
      '#theme' => 'username',
      '#account' => $revision->uid->entity,
    );
    $revision_date = $this->date
      ->format($revision
      ->getRevisionCreationTime(), 'short');
    $revision_link = $this
      ->t($revision_log . '@date', array(
      '@date' => $this
        ->l($revision_date, Url::fromRoute('entity.support_ticket.revision', array(
        'support_ticket' => $revision
          ->id(),
        'support_ticket_revision' => $revision
          ->getRevisionId(),
      ))),
    ));

    // @todo When theming think about where in the table to integrate this
    //   link to the revision user. There is some issue about multi-line headers
    //   for theme table.
    // $header[] = array(
    //   'data' => $this->t('by' . '!username', array('!username' => drupal_render($username))),
    //   'colspan' => 1,
    // );
    $header[] = array(
      'data' => array(
        '#markup' => $this->nonBreakingSpace,
      ),
      'colspan' => 1,
    );
    $header[] = array(
      'data' => array(
        '#markup' => $revision_link,
      ),
      'colspan' => 1,
    );
  }
  return $header;
}