You are here

public function SupportTicketListBuilder::buildRow in Support Ticketing System 8

Builds a row for an entity in the entity listing.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity for this row of the list.

Return value

array A render array structure of fields for this entity.

Overrides EntityListBuilder::buildRow

See also

\Drupal\Core\Entity\EntityListBuilder::render()

File

modules/support_ticket/src/SupportTicketListBuilder.php, line 105
Contains \Drupal\support_ticket\SupportTicketListBuilder.

Class

SupportTicketListBuilder
Defines a class to build a listing of support ticket entities.

Namespace

Drupal\support_ticket

Code

public function buildRow(EntityInterface $entity) {

  /** @var \Drupal\support_ticket\SupportTicketInterface $entity */
  $mark = array(
    '#theme' => 'mark',
    '#mark_type' => support_ticket_mark($entity
      ->id(), $entity
      ->getChangedTime()),
  );
  $langcode = $entity
    ->language()
    ->getId();
  $uri = $entity
    ->urlInfo();
  $options = $uri
    ->getOptions();
  $options += $langcode != LanguageInterface::LANGCODE_NOT_SPECIFIED && isset($languages[$langcode]) ? array(
    'language' => $languages[$langcode],
  ) : array();
  $uri
    ->setOptions($options);
  $row['title']['data'] = array(
    '#type' => 'link',
    '#title' => $entity
      ->label(),
    '#suffix' => ' ' . drupal_render($mark),
    '#url' => $uri,
  );
  $row['type'] = SafeMarkup::checkPlain(support_ticket_get_type_label($entity));

  // @todo implement support_ticket_get_type_label
  $row['author']['data'] = array(
    '#theme' => 'username',
    '#account' => $entity
      ->getOwner(),
  );
  $row['status'] = $entity
    ->isPublished() ? $this
    ->t('published') : $this
    ->t('not published');
  $row['changed'] = $this->dateFormatter
    ->format($entity
    ->getChangedTime(), 'short');
  $language_manager = \Drupal::languageManager();
  if ($language_manager
    ->isMultilingual()) {
    $row['language_name'] = $language_manager
      ->getLanguageName($langcode);
  }
  $row['operations']['data'] = $this
    ->buildOperations($entity);
  return $row + parent::buildRow($entity);
}