You are here

public function ContentModerationNotificationsListBuilder::buildRow in Content Moderation Notifications 8.2

Same name and namespace in other branches
  1. 8.3 src/Controller/ContentModerationNotificationsListBuilder.php \Drupal\content_moderation_notifications\Controller\ContentModerationNotificationsListBuilder::buildRow()
  2. 8 src/Controller/ContentModerationNotificationsListBuilder.php \Drupal\content_moderation_notifications\Controller\ContentModerationNotificationsListBuilder::buildRow()

Builds a row for an entity in the entity listing.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity for which to build the row.

Return value

array A render array of the table row for displaying the entity.

Overrides EntityListBuilder::buildRow

See also

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

File

src/Controller/ContentModerationNotificationsListBuilder.php, line 60

Class

ContentModerationNotificationsListBuilder
Provides a listing of content_moderation_notification entities.

Namespace

Drupal\content_moderation_notifications\Controller

Code

public function buildRow(EntityInterface $entity) {

  // Load the workflow @todo change to dependency injection.
  $workflow = \Drupal::entityTypeManager()
    ->getStorage('workflow')
    ->load($entity->workflow);

  // Load the transitions in this workflow.
  $workflow_transitions = $workflow
    ->getTransitions();
  $row = [];

  // Array of transitions used in each row.
  $transition_strings = [];

  // Loop through the saved transitions.
  if ($entity->transitions) {
    $transitions = array_keys(array_filter($entity->transitions));
  }
  foreach ($transitions as $transition) {
    $transition_strings[] = $workflow_transitions[$transition]
      ->label();
  }
  $row['workflow'] = $workflow
    ->label();
  $row['status'] = $entity
    ->status() ? $this
    ->t('Enabled') : $this
    ->t('Disabled');
  $row['transition'] = implode(', ', $transition_strings);
  $roles = [];
  if ($entity->roles) {
    $roles = array_keys(array_filter($entity->roles));
  }
  $row['roles'] = implode(', ', $roles);
  $row['author'] = $entity->author ? $this
    ->t('Yes') : $this
    ->t('No');
  $row['emails'] = $entity->emails;
  return $row + parent::buildRow($entity);
}