Reverts data item translation to the latest existing revision.
array $key: Data item key that should be reverted.
bool Result of the revert action.
Overrides JobItemInterface::dataItemRevert
public function dataItemRevert(array $key) {
$data = $this
->getData($key);
if (!empty($data['#translation']['#text_revisions'])) {
$prev_revision = end($data['#translation']['#text_revisions']);
$data['#translation']['#text_revisions'][] = array(
'#text' => $data['#translation']['#text'],
'#timestamp' => $data['#translation']['#timestamp'],
'#origin' => $data['#translation']['#origin'],
);
$data['#translation']['#text'] = $prev_revision['#text'];
$data['#translation']['#origin'] = $prev_revision['#origin'];
$data['#translation']['#timestamp'] = $prev_revision['#timestamp'];
$this
->updateData($key, $data);
$this
->addMessage('Translation for @key reverted to the latest version.', array(
'@key' => $key[0],
));
return TRUE;
}
return FALSE;
}