You are here

public function WorkflowListBuilder::getDefaultOperations in Forms Steps 8

Gets this list's default operations.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity the operations are for.

Return value

array The array structure is identical to the return value of self::getOperations().

Overrides EntityListBuilder::getDefaultOperations

File

src/Controller/WorkflowListBuilder.php, line 59

Class

WorkflowListBuilder
Defines a class to build a listing of Workflow entities.

Namespace

Drupal\forms_steps\Controller

Code

public function getDefaultOperations(EntityInterface $entity) {

  /** @var \Drupal\Core\Config\Entity\ConfigEntityInterface $entity */
  $operations = parent::getDefaultOperations($entity);

  /** @var \Drupal\forms_steps\Service\FormsStepsManager $formStepsManager */
  $formStepsManager = \Drupal::service('forms_steps.manager');
  if ($entity->forms_steps->value) {

    /** @var \Drupal\forms_steps\Entity\FormsSteps $formsSteps */
    $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;
}