public function ConfigEntityRevisionsModerationHandler::onPresave in Config Entity Revisions 8
Same name and namespace in other branches
- 8.2 src/Entity/Handler/ConfigEntityRevisionsModerationHandler.php \Drupal\config_entity_revisions\Entity\Handler\ConfigEntityRevisionsModerationHandler::onPresave()
- 1.x src/Entity/Handler/ConfigEntityRevisionsModerationHandler.php \Drupal\config_entity_revisions\Entity\Handler\ConfigEntityRevisionsModerationHandler::onPresave()
Operates on moderated content entities preSave().
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/ ConfigEntityRevisionsModerationHandler.php, line 49 - Contains Drupal\config_entity_revisions\Entity\Handler\ConfigEntityRevisionsModerationHandler.
Class
- ConfigEntityRevisionsModerationHandler
- Customizations for config_entity_revisions entities.
Namespace
Drupal\config_entity_revisions\Entity\HandlerCode
public function onPresave(ContentEntityInterface $entity, $default_revision, $published_state) {
// Updating an existing revision?
if (!$entity
->isNewRevision()) {
return;
}
$entity
->setNewRevision(TRUE);
$entity
->isDefaultRevision($default_revision);
// Update publishing status if it can be updated and if it needs updating.
if ($entity instanceof EntityPublishedInterface && $entity
->isPublished() !== $published_state) {
$published_state ? $entity
->setPublished() : $entity
->setUnpublished();
}
}