ServiceEndpointListBuilder.php in Services 8.4
File
src/Controller/ServiceEndpointListBuilder.php
View source
<?php
namespace Drupal\services\Controller;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Entity\EntityInterface;
class ServiceEndpointListBuilder extends ConfigEntityListBuilder {
public function buildHeader() {
$header['label'] = $this
->t('Services endpoint');
$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 getOperations(EntityInterface $entity) {
$operations = parent::getOperations($entity);
if ($entity
->hasLinkTemplate('resources')) {
$operations['resource'] = [
'title' => $this
->t('Resources'),
'url' => $entity
->toUrl('resources'),
'weight' => 10,
];
}
return $operations;
}
}