function Drafty::publishRevision in Drafty 7
Publish a revision.
Parameters
$type: The entity type.
$vid: The entity version ID.
Return value
The newly published revision.
1 call to Drafty::publishRevision()
- Drafty::restorePublishedRevisions in ./
drafty.module - Publish revisions previously set with setRevisionToBePublished().
File
- ./
drafty.module, line 273 - Hook implementations and API functions for the Drafty module.
Class
- Drafty
- Handles tracking, selecting and publishing revisions.
Code
function publishRevision($type, $id, $vid) {
// Title module assumes that the current content language is used when
// saving an entity. This is OK for the new draft revision, but it does not
// work when publishing a revision. Therefore, ensure that
// title_active_language() reflects the original language of the entity.
// Without this, title may overwrite {$title}_field in the original language
// with the contents of the legacy field.
// @todo: this might not be necessary after one or both of these patches
// lands:
// https://www.drupal.org/node/2267251
// https://www.drupal.org/node/2098097
if (module_exists('title')) {
$entity = entity_load_single($type, $id);
$langcode = entity_language($type, $entity);
title_active_language($langcode);
}
$revision = entity_revision_load($type, $vid);
// Publishing a revision sometimes happens within hook_entity_update(). When
// we do that, set $entity->original to the entity we're in the process of
// saving. i.e. the draft we're in the process of creating and need to
// replace with the published version again.
$revision->is_draft_revision = FALSE;
return $this
->saveRevisionAsNew($type, $revision);
}