You are here

public function StockLocationListBuilder::buildRow in Commerce Stock 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

modules/local_storage/src/StockLocationListBuilder.php, line 30

Class

StockLocationListBuilder
Defines a class to build a listing of stock location entities.

Namespace

Drupal\commerce_stock_local

Code

public function buildRow(EntityInterface $entity) {

  /** @var \Drupal\commerce_stock_local\Entity\StockLocationType $location_type */
  $location_type = StockLocationType::load($entity
    ->bundle());
  $row['id'] = $entity
    ->id();
  $row['name']['data'] = [
    '#type' => 'link',
    '#title' => $entity
      ->label(),
  ] + $entity
    ->toUrl()
    ->toRenderArray();
  $row['type'] = $location_type
    ->label();
  $row['status'] = $entity
    ->isActive() ? $this
    ->t('Active') : $this
    ->t('Inactive');
  return $row + parent::buildRow($entity);
}