You are here

public function ConsumerListBuilder::buildRow in Consumers 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/ConsumerListBuilder.php, line 30

Class

ConsumerListBuilder
Defines a class to build a listing of Access Token entities.

Namespace

Drupal\consumers

Code

public function buildRow(EntityInterface $entity) {

  /* @var $entity \Drupal\consumers\Entity\Consumer */
  $row['uuid'] = $entity
    ->uuid();
  $row['label'] = $entity
    ->toLink();
  $ops = [
    '#type' => 'operations',
    '#links' => [
      [
        'title' => $this
          ->t('Make Default'),
        'url' => $entity
          ->toUrl('make-default-form', [
          'query' => $this
            ->getDestinationArray(),
        ]),
      ],
    ],
  ];
  $row['is_default'] = $entity
    ->get('is_default')->value ? [
    'data' => $this
      ->t('Default'),
  ] : [
    'data' => $ops,
  ];
  $context = [
    'type' => 'row',
    'entity' => $entity,
  ];
  $this
    ->moduleHandler()
    ->alter('consumers_list', $row, $context);
  $row = $row + parent::buildRow($entity);
  return $row;
}