You are here

public function ContentModerationNotificationsListBuilder::buildRow in Content Moderation Notifications 8

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

Builds a row for an entity in the entity listing.

Parameters

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 59

Class

ContentModerationNotificationsListBuilder
Provides a listing of content_moderation_notification entities.

Namespace

Drupal\content_moderation_notifications\Controller

Code

public function buildRow(EntityInterface $entity) {
  $row = array(
    'transition' => '',
  );

  // Array of transitions used in each row.
  $transition_strings = array();

  // Loop through the saved transitions.
  if ($entity->transitions) {
    $transitions = array_keys(array_filter($entity->transitions));
  }
  foreach ($transitions as $transition) {
    $transition = \Drupal::service('entity_type.manager')
      ->getStorage('moderation_state_transition')
      ->load($transition);
    $from = \Drupal::service('entity_type.manager')
      ->getStorage('moderation_state')
      ->load($transition
      ->getFromState())
      ->label();
    $to = \Drupal::service('entity_type.manager')
      ->getStorage('moderation_state')
      ->load($transition
      ->getToState())
      ->label();
    $transition_strings[] = $from . ' to ' . $to;
  }
  $row['transition'] = implode(', ', $transition_strings);
  $bundles = array();
  if ($entity->bundles) {
    $bundles = array_keys(array_filter($entity->bundles));
  }
  $roles = array();
  if ($entity->roles) {
    $roles = array_keys(array_filter($entity->roles));
  }
  $row['bundles'] = implode(', ', $bundles);
  $row['roles'] = implode(', ', $roles);
  $row['author'] = $entity->author ? 'Yes' : 'No';
  $row['emails'] = $entity->emails;
  return $row + parent::buildRow($entity);
}