EntityTypeInfo::entityOperation

public EntityTypeInfo::entityOperation(EntityInterface $entity)

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

core/modules/content_moderation/src/EntityTypeInfo.php, line 195

Class

EntityTypeInfo
Manipulates entity type information.

Namespace

Drupal\content_moderation

Code

public function entityOperation(EntityInterface $entity) {
  $operations = [];
  $type = $entity->getEntityType();
  $bundle_of = $type->getBundleOf();
  if ($this->currentUser->hasPermission('administer moderation states') && $bundle_of && 
    $this->moderationInfo->canModerateEntitiesOfEntityType($this->entityTypeManager->getDefinition($bundle_of))
    ) {
    $operations['manage-moderation'] = [
      'title' => t('Manage moderation'),
      'weight' => 27,
      'url' => Url::fromRoute("entity.{$type->id()}.moderation", [$entity->getEntityTypeId() => $entity->id()]),
    ];
  }

  return $operations;
}
doc_Drupal
2016-10-29 09:08:17
Comments
Leave a Comment

Please login to continue.