You are here

public function LayoutListBuilder::buildRow in Layout builder library 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/Entity/LayoutListBuilder.php, line 92

Class

LayoutListBuilder
Defines a list builder for layouts.

Namespace

Drupal\layout_library\Entity

Code

public function buildRow(EntityInterface $entity) {

  /** @var \Drupal\layout_library\Entity\Layout $entity */
  $targetEntityTypeId = $entity
    ->getTargetEntityType();
  $bundle_info = $this->bundleInfo
    ->getBundleInfo($targetEntityTypeId);
  $bundle_name = isset($bundle_info[$entity
    ->getTargetBundle()]) ? $bundle_info[$entity
    ->getTargetBundle()]['label'] : $entity
    ->getTargetBundle();
  $row = [
    'label' => [
      'data' => $entity
        ->label(),
    ],
    'entity_type_id' => [
      'data' => $this->entityTypeManager
        ->getDefinition($targetEntityTypeId)
        ->getLabel(),
    ],
    'bundle' => [
      'data' => $bundle_name,
    ],
  ];
  return $row + parent::buildRow($entity);
}