EntityOperations::entityView

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

hook_entity_view()

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'];
  }
}
doc_Drupal
2016-10-29 09:07:17
Comments
Leave a Comment

Please login to continue.