You are here

public function WorkflowListBuilder::getDefaultOperations in Workflow 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/WorkflowListBuilder.php, line 46

Class

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

Namespace

Drupal\workflow

Code

public function getDefaultOperations(EntityInterface $entity) {
  $operations = parent::getDefaultOperations($entity);

  /** @var \Drupal\workflow\Entity\Workflow $workflow */
  $workflow = $entity;

  // Do not delete a Workflow if it contains content.
  if (isset($operations['delete']) && !$workflow
    ->isDeletable()) {
    unset($operations['delete']);
  }

  /*
   * Allow modules to insert their own workflow operations to the list.
   */

  // This is what EntityListBuilder::getOperations() does:
  // $operations = $this->getDefaultOperations($entity);
  // $operations += $this->moduleHandler()->invokeAll('entity_operation', [$entity]);
  // $this->moduleHandler->alter('entity_operation', $operations, $entity);
  // In D8, the interface of below hook_workflow_operations has changed a bit.
  // @see EntityListBuilder::getOperations, workflow_operations, workflow.api.php.
  $operations += $this
    ->moduleHandler()
    ->invokeAll('workflow_operations', [
    'workflow',
    $workflow,
  ]);
  return $operations;
}