You are here

public function ModerationHandler::onPresave in Workbench Moderation 8.2

Same name and namespace in other branches
  1. 8 src/Entity/Handler/ModerationHandler.php \Drupal\workbench_moderation\Entity\Handler\ModerationHandler::onPresave()

Parameters

\Drupal\Core\Entity\ContentEntityInterface $entity: The entity to modify.

bool $default_revision: Whether the new revision should be made the default revision.

bool $published_state: Whether the state being transitioned to is a published state or not.

Overrides ModerationHandlerInterface::onPresave

1 call to ModerationHandler::onPresave()
NodeModerationHandler::onPresave in src/Entity/Handler/NodeModerationHandler.php
1 method overrides ModerationHandler::onPresave()
NodeModerationHandler::onPresave in src/Entity/Handler/NodeModerationHandler.php

File

src/Entity/Handler/ModerationHandler.php, line 37
Contains Drupal\workbench_moderation\Entity\Handler\GenericCustomizations.

Class

ModerationHandler
Common customizations for most/all entities.

Namespace

Drupal\workbench_moderation\Entity\Handler

Code

public function onPresave(ContentEntityInterface $entity, $default_revision, $published_state) {

  // This is *probably* not necessary if configuration is setup correctly,
  // but it can't hurt.
  $entity
    ->setNewRevision(TRUE);
  $entity
    ->isDefaultRevision($default_revision);
}