You are here

public function FormsStepsListBuilder::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 ConfigEntityListBuilder::getDefaultOperations

File

src/Controller/FormsStepsListBuilder.php, line 45

Class

FormsStepsListBuilder
Defines a class to build a listing of FormsSteps entities.

Namespace

Drupal\forms_steps\Controller

Code

public function getDefaultOperations(EntityInterface $entity) {

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

  // View action is only displayed when the forms steps has at least one step.
  if ($first_step) {
    $uri = $first_step
      ->url();
    $operations['display'] = [
      'title' => $this
        ->t('View'),
      'weight' => 20,
      'url' => Url::fromUri("internal:{$uri}"),
    ];
  }
  return $operations;
}