You are here

protected function SupportTicketRevisionController::buildRevisionsNavigation in Support Ticketing System 8

Returns the navigation row for diff table.

1 call to SupportTicketRevisionController::buildRevisionsNavigation()
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 215
Contains \Drupal\support_ticket\Controller\SupportTicketRevisionController.

Class

SupportTicketRevisionController
Returns responses for Support Ticket Revision routes.

Namespace

Drupal\support_ticket\Controller

Code

protected function buildRevisionsNavigation($stid, $vids, $left_vid, $right_vid) {
  $revisions_count = count($vids);
  $i = 0;
  $row = array();

  // Find the previous revision.
  while ($left_vid > $vids[$i]) {
    $i += 1;
  }
  if ($i != 0) {

    // Second column.
    $row[] = array(
      'data' => $this
        ->l($this
        ->t('< Previous difference'), Url::fromRoute('support_ticket.revisions_diff', array(
        'support_ticket' => $stid,
        'left_vid' => $vids[$i - 1],
        'right_vid' => $left_vid,
      ))),
      'colspan' => 2,
      'class' => 'rev-navigation',
    );
  }
  else {

    // Second column.
    $row[] = $this->nonBreakingSpace;
  }

  // Third column.
  $row[] = $this->nonBreakingSpace;

  // Find the next revision.
  $i = 0;
  while ($i < $revisions_count && $right_vid >= $vids[$i]) {
    $i += 1;
  }
  if ($revisions_count != $i && $vids[$i - 1] != $vids[$revisions_count - 1]) {

    // Forth column.
    $row[] = array(
      'data' => $this
        ->l($this
        ->t('Next difference >'), Url::fromRoute('support_ticket.revisions_diff', array(
        'support_ticket' => $stid,
        'left_vid' => $right_vid,
        'right_vid' => $vids[$i],
      ))),
      'colspan' => 2,
      'class' => 'rev-navigation',
    );
  }
  else {

    // Forth column.
    $row[] = $this->nonBreakingSpace;
  }

  // If there are only 2 revision return an empty row.
  if ($revisions_count == 2) {
    return array();
  }
  else {
    return $row;
  }
}