public EntityOperations::entityView(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode)
Act on entities being assembled before rendering.
This is a hook bridge.
See also
EntityFieldManagerInterface::getExtraFields()
File
- core/modules/content_moderation/src/EntityOperations.php, line 214
 
Class
- EntityOperations
 - Defines a class for reacting to entity events.
 
Namespace
Drupal\content_moderation
Code
public function entityView(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
  if (!$this->moderationInfo->isModeratedEntity($entity)) {
    return;
  }
  if (!$this->moderationInfo->isLatestRevision($entity)) {
    return;
  }
  /** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
  if ($entity->isDefaultRevision()) {
    return;
  }
  $component = $display->getComponent('content_moderation_control');
  if ($component) {
    $build['content_moderation_control'] = $this->formBuilder->getForm(EntityModerationForm::class, $entity);
    $build['content_moderation_control']['#weight'] = $component['weight'];
  }
}
Please login to continue.