PriceModifierListBuilder.php in Price 8
File
src/PriceModifierListBuilder.php
View source
<?php
namespace Drupal\price;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Entity\EntityInterface;
class PriceModifierListBuilder extends ConfigEntityListBuilder {
public function buildHeader() {
$header['label'] = $this->entityType
->getLabel();
return $header + parent::buildHeader();
}
public function buildRow(EntityInterface $entity) {
$row['label'] = $entity
->toLink($entity
->label(), 'edit-form');
return $row + parent::buildRow($entity);
}
public function getOperations(EntityInterface $entity) {
$operations = parent::getOperations($entity);
if (isset($operations['edit'])) {
$operations['edit'] = [
'title' => t('Edit'),
'weight' => 30,
'url' => $entity
->toUrl('edit-form'),
];
}
if (isset($operations['delete'])) {
$operations['delete'] = [
'title' => t('Delete'),
'weight' => 35,
'url' => $entity
->toUrl('delete-form'),
];
}
uasort($operations, [
'Drupal\\Component\\Utility\\SortArray',
'sortByWeightElement',
]);
return $operations;
}
}