You are here

public function EntityTypeInfo::entityOperation in Workbench Moderation 8.2

Same name and namespace in other branches
  1. 8 src/EntityTypeInfo.php \Drupal\workbench_moderation\EntityTypeInfo::entityOperation()

Adds an operation on bundles that should have a Moderation form.

Parameters

\Drupal\Core\Entity\EntityInterface $entity: The entity on which to define an operation.

Return value

array An array of operation definitions.

See also

hook_entity_operation().

File

src/EntityTypeInfo.php, line 166

Class

EntityTypeInfo
Service class for manipulating entity type information.

Namespace

Drupal\workbench_moderation

Code

public function entityOperation(EntityInterface $entity) {
  $operations = [];
  $type = $entity
    ->getEntityType();
  if ($this->moderationInfo
    ->isBundleForModeratableEntity($entity)) {
    $operations['manage-moderation'] = [
      'title' => t('Manage moderation'),
      'weight' => 27,
      'url' => Url::fromRoute("entity.{$type->id()}.moderation", [
        $entity
          ->getEntityTypeId() => $entity
          ->id(),
      ]),
    ];
  }
  return $operations;
}