You are here

public function EntityOperations::entityPresave in Radioactivity 8.3

Same name and namespace in other branches
  1. 4.0.x 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

hook_entity_presave()

File

src/EntityOperations.php, line 87

Class

EntityOperations
Defines a class for reacting to entity events.

Namespace

Drupal\radioactivity

Code

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);
  }
}