FormsStepsListBuilder.php in Forms Steps 8
File
src/Controller/FormsStepsListBuilder.php
View source
<?php
namespace Drupal\forms_steps\Controller;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Config\Entity\ConfigEntityListBuilder;
use Drupal\Core\Url;
class FormsStepsListBuilder extends ConfigEntityListBuilder {
public function buildHeader() {
$header['id'] = $this
->t('ID');
$header['label'] = $this
->t('Label');
$header['description'] = $this
->t('Description');
return $header + parent::buildHeader();
}
public function buildRow(EntityInterface $entity) {
$row['id'] = $entity
->id();
$row['label'] = $entity
->label();
$row['description'] = $entity
->getDescription();
return $row + parent::buildRow($entity);
}
public function getDefaultOperations(EntityInterface $entity) {
$operations = parent::getDefaultOperations($entity);
$first_step = $entity
->getFirstStep();
if ($first_step) {
$uri = $first_step
->url();
$operations['display'] = [
'title' => $this
->t('View'),
'weight' => 20,
'url' => Url::fromUri("internal:{$uri}"),
];
}
return $operations;
}
}