public function ContentModerationNotificationsListBuilder::buildRow in Content Moderation Notifications 8.3
Same name and namespace in other branches
- 8 src/Controller/ContentModerationNotificationsListBuilder.php \Drupal\content_moderation_notifications\Controller\ContentModerationNotificationsListBuilder::buildRow()
- 8.2 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 61
Class
- ContentModerationNotificationsListBuilder
- Provides a listing of content_moderation_notification entities.
Namespace
Drupal\content_moderation_notifications\ControllerCode
public function buildRow(EntityInterface $entity) {
// Load the workflow @todo change to dependency injection.
/** @var \Drupal\workflows\WorkflowInterface $workflow */
$workflow = \Drupal::entityTypeManager()
->getStorage('workflow')
->load($entity->workflow);
// Load the transitions in this workflow.
$workflow_transitions = $workflow
->getTypePlugin()
->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) {
if (!empty($workflow_transitions[$transition])) {
$transition_strings[] = $workflow_transitions[$transition]
->label();
}
}
$row['label'] = $entity
->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);
}