You are here

public function ConfigEntityRevisionsRevertFormBase::prepareToPublishCurrentRevision in Config Entity Revisions 8.2

Same name and namespace in other branches
  1. 8 src/ConfigEntityRevisionsRevertFormBase.php \Drupal\config_entity_revisions\ConfigEntityRevisionsRevertFormBase::prepareToPublishCurrentRevision()
  2. 1.x src/ConfigEntityRevisionsRevertFormBase.php \Drupal\config_entity_revisions\ConfigEntityRevisionsRevertFormBase::prepareToPublishCurrentRevision()

Modify the revision's fields so that it becomes published.

Parameters

\Drupal\config_entity_revisions\ConfigEntityRevisions $revision: The revision to be published.

Return value

\Drupal\config_entity_revisions\ConfigEntityRevisionsConfigEntityInterface The resulting revision record, ready to be saved.

1 call to ConfigEntityRevisionsRevertFormBase::prepareToPublishCurrentRevision()
ConfigEntityRevisionsRevertFormBase::applyRevisionChange in src/ConfigEntityRevisionsRevertFormBase.php
Apply the revision insert/update.
1 method overrides ConfigEntityRevisionsRevertFormBase::prepareToPublishCurrentRevision()
ConfigEntityRevisionsRevertFormTest2::prepareToPublishCurrentRevision in tests/src/Unit/ConfigEntityRevisionsRevertFormBaseTest.php
Override prepareToPublishCurrentRevision to ensure it is actually called.

File

src/ConfigEntityRevisionsRevertFormBase.php, line 232

Class

ConfigEntityRevisionsRevertFormBase
Class ConfigEntityRevisionsRevertFormBase.

Namespace

Drupal\config_entity_revisions

Code

public function prepareToPublishCurrentRevision(ConfigEntityRevisions $revision) {
  if ($revision
    ->hasField('moderation_state')) {
    $revision
      ->set('moderation_state', 'published');
  }
  $revision
    ->setPublished();
  $revision
    ->isDefaultRevision(TRUE);
  return $revision;
}