public function TMGMTJobItem::dataItemRevert in Translation Management Tool 7
Reverts data item translation to the latest existing revision.
Parameters
array $key: Data item key that should be reverted.
Return value
bool Result of the revert action.
File
- entity/
tmgmt.entity.job_item.inc, line 649
Class
- TMGMTJobItem
- Entity class for the tmgmt_job entity.
Code
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' => tmgmt_ensure_keys_string($key),
));
return TRUE;
}
return FALSE;
}