You are here

public function ProtectionRuleListBuilder::buildRow in User protect 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

src/Controller/ProtectionRuleListBuilder.php, line 29

Class

ProtectionRuleListBuilder
Provides a listing of protection rules.

Namespace

Drupal\userprotect\Controller

Code

public function buildRow(EntityInterface $entity) {
  $row['label'] = $entity
    ->label();
  $protected_entity = $entity
    ->getProtectedEntity();
  if ($protected_entity instanceof EntityInterface) {
    $row['entity'] = $protected_entity
      ->label();
  }
  else {
    $row['entity'] = new FormattableMarkup('%missing', [
      '%missing' => $this
        ->t('Missing'),
    ]);
  }
  $row['type'] = $entity
    ->getProtectedEntityTypeId();
  $row['protection'] = $this
    ->getProtections($entity);
  return $row + parent::buildRow($entity);
}