ProfileTypeListBuilder.php in Profile 8
File
src/ProfileTypeListBuilder.php
View source
<?php
namespace Drupal\profile;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
class ProfileTypeListBuilder extends ConfigEntityListBuilder {
public function buildHeader() {
$header['type'] = $this
->t('Profile type');
$header['registration'] = $this
->t('Registration');
$header['multiple'] = $this
->t('Allow multiple profiles');
return $header + parent::buildHeader();
}
public function buildRow(EntityInterface $entity) {
$row['type'] = $entity
->toLink(NULL, 'edit-form');
$row['registration'] = $entity
->getRegistration() ? $this
->t('Yes') : $this
->t('No');
$row['multiple'] = $entity
->allowsMultiple() ? $this
->t('Yes') : $this
->t('No');
return $row + parent::buildRow($entity);
}
public function getOperations(EntityInterface $entity) {
$operations = parent::getOperations($entity);
if (isset($operations['edit'])) {
$operations['edit'] = [
'title' => $this
->t('Edit'),
'weight' => 30,
'url' => $entity
->toUrl('edit-form'),
];
}
if (isset($operations['delete'])) {
$operations['delete'] = [
'title' => $this
->t('Delete'),
'weight' => 35,
'url' => $entity
->toUrl('delete-form'),
];
}
uasort($operations, [
'Drupal\\Component\\Utility\\SortArray',
'sortByWeightElement',
]);
return $operations;
}
}