public function EntityOperations::entityPresave in Radioactivity 4.0.x
Same name and namespace in other branches
- 8.3 src/EntityOperations.php \Drupal\radioactivity\EntityOperations::entityPresave()
Acts on an entity and set published status based on the moderation state.
Parameters
\Drupal\Core\Entity\EntityInterface $entity: The entity being saved.
See also
File
- src/
EntityOperations.php, line 87
Class
- EntityOperations
- Defines a class for reacting to entity events.
Namespace
Drupal\radioactivityCode
public function entityPresave(EntityInterface $entity) {
// Check if the entity is being updated by the radioactivity processor.
if (!isset($entity->radioactivityUpdate)) {
return;
}
if (!$this->moduleHandler
->moduleExists('content_moderation') || !$this
->entityLeveragesContentModeration($entity)) {
// Entity is not using content moderation, so we don't have to implement
// our work around.
return;
}
// Prevent the Content Moderation module from creating a new revision.
if ($entity instanceof RevisionableInterface) {
$entity
->setNewRevision(FALSE);
}
}