You are here

public function NodeModerationHandler::onPresave in Workbench Moderation 8.2

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 ModerationHandler::onPresave

File

src/Entity/Handler/NodeModerationHandler.php, line 21
Contains Drupal\workbench_moderation\Entity\Handler\NodeCustomizations.

Class

NodeModerationHandler
Customizations for node entities.

Namespace

Drupal\workbench_moderation\Entity\Handler

Code

public function onPresave(ContentEntityInterface $entity, $default_revision, $published_state) {
  if ($this
    ->shouldModerate($entity)) {
    parent::onPresave($entity, $default_revision, $published_state);

    // Only nodes have a concept of published.

    /** @var $entity Node */
    $entity
      ->setPublished($published_state);
  }
}