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
File
- core/modules/content_moderation/src/EntityTypeInfo.php, line 195
Class
- EntityTypeInfo
- Manipulates entity type information.
Namespace
Drupal\content_moderation
Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | 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 ; } |
Please login to continue.