HomeboxListBuilder.php in Homebox 8
File
src/HomeboxListBuilder.php
View source
<?php
namespace Drupal\homebox;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Url;
class HomeboxListBuilder extends ConfigEntityListBuilder {
public function buildHeader() {
$header['label'] = $this
->t('Homebox');
$header['id'] = $this
->t('Machine name');
return $header + parent::buildHeader();
}
public function buildRow(EntityInterface $entity) {
$row['label'] = $entity
->label();
$row['id'] = $entity
->id();
return $row + parent::buildRow($entity);
}
public function getDefaultOperations(EntityInterface $entity) {
$operations = parent::getDefaultOperations($entity);
if ($entity
->access('update') && $entity
->hasLinkTemplate('settings-form')) {
$operations['layout'] = [
'title' => $this
->t('Settings'),
'weight' => 20,
'url' => $this
->ensureDestination(Url::fromRoute('homebox.settings_form', [
'homebox' => $entity
->id(),
])),
];
}
return $operations;
}
}