public function EntityOperations::entityView in Config Entity Revisions 8.2
Act on entities being assembled before rendering.
See also
EntityFieldManagerInterface::getExtraFields()
File
- src/
EntityOperations.php, line 294
Class
- EntityOperations
- Defines a class for reacting to entity events.
Namespace
Drupal\config_entity_revisionsCode
public function entityView(array &$build, EntityInterface $entity, EntityViewDisplayInterface $display, $view_mode) {
/** @var \Drupal\Core\Entity\ContentEntityInterface $entity */
if (!$this->moderationInfo
->isModeratedEntity($entity)) {
return;
}
if (isset($entity->in_preview) && $entity->in_preview) {
return;
}
// If the component is not defined for this display, we have nothing to do.
if (!$display
->getComponent('content_moderation_control')) {
return;
}
// The moderation form should be displayed only when viewing the latest
// (translation-affecting) revision, unless it was created as published
// default revision.
if (($entity
->isDefaultRevision() || $entity
->wasDefaultRevision()) && $this
->isPublished($entity)) {
return;
}
if (!$entity
->isLatestRevision() && !$entity
->isLatestTranslationAffectedRevision()) {
return;
}
$build['content_moderation_control'] = $this->formBuilder
->getForm(EntityModerationForm::class, $entity);
}