WorkflowListBuilder.php in Forms Steps 8
File
src/Controller/WorkflowListBuilder.php
View source
<?php
namespace Drupal\forms_steps\Controller;
use Drupal\Core\Entity\EntityInterface;
use Drupal\Core\Entity\EntityListBuilder;
use Drupal\Core\Url;
use Drupal\forms_steps\Service\RouteHelper;
use Drupal\forms_steps\Step;
class WorkflowListBuilder extends EntityListBuilder {
public function buildHeader() {
$header['id'] = $this
->t('ID');
$header['instance_id'] = $this
->t('Instance ID');
$header['entity_type'] = $this
->t('Entity Type');
$header['bundle'] = $this
->t('Bundle');
$header['entity_id'] = $this
->t('Entity ID');
$header['form_mode'] = $this
->t('Form Mode');
$header['forms_steps'] = $this
->t('Workflow Name');
$header['step'] = $this
->t('Step');
return $header + parent::buildHeader();
}
public function buildRow(EntityInterface $entity) {
$row['id'] = $entity
->id();
$row['instance_id'] = $entity->instance_id->value;
$row['entity_type'] = $entity->entity_type->value;
$row['bundle'] = $entity->bundle->value;
$row['entity_id'] = $entity->entity_id->value;
$row['form_mode'] = $entity->form_mode->value;
$row['forms_steps'] = $entity->forms_steps->value;
$row['step'] = $entity->step->value;
return $row + parent::buildRow($entity);
}
public function getDefaultOperations(EntityInterface $entity) {
$operations = parent::getDefaultOperations($entity);
$formStepsManager = \Drupal::service('forms_steps.manager');
if ($entity->forms_steps->value) {
$formsSteps = $formStepsManager
->getFormsStepsById($entity->forms_steps->value);
if ($formsSteps) {
$operations['display'] = [
'title' => $this
->t('View'),
'weight' => 20,
'url' => Url::fromUri("internal:" . RouteHelper::getStepUrl($formsSteps
->getStep($entity->step->value), $entity->instance_id->value)),
];
}
}
return $operations;
}
}