StockLocationListBuilder.php in Commerce Stock 8
File
modules/local_storage/src/StockLocationListBuilder.php
View source
<?php
namespace Drupal\commerce_stock_local;
use Drupal\commerce_stock_local\Entity\StockLocationType;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityListBuilder;
class StockLocationListBuilder extends EntityListBuilder {
public function buildHeader() {
$header['id'] = $this
->t('Location ID');
$header['name'] = $this
->t('Name');
$header['type'] = $this
->t('Type');
$header['status'] = $this
->t('Status');
return $header + parent::buildHeader();
}
public function buildRow(EntityInterface $entity) {
$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);
}
}