public function loadhistory($version_id, $alias)
{
// Only attempt to check the row in if it exists.
if (!$version_id) {
throw new RecordNotLoaded();
}
// Get an instance of the row to checkout.
$historyTable = \JTable::getInstance('Contenthistory');
if (!$historyTable->load($version_id)) {
throw new BaseException($historyTable->getError());
}
$rowArray = \JArrayHelper::fromObject(json_decode($historyTable->version_data));
$typeId = \JTable::getInstance('Contenttype')->getTypeId($alias);
if ($historyTable->ucm_type_id != $typeId) {
$key = $this->getKeyName();
if (isset($rowArray[$key])) {
$this->{$this->idFieldName} = $rowArray[$key];
$this->unlock();
}
throw new BaseException(\JText::_('JLIB_APPLICATION_ERROR_HISTORY_ID_MISMATCH'));
}
$this->setState('save_date', $historyTable->save_date);
$this->setState('version_note', $historyTable->version_note);
$this->bind($rowArray);
return true;
}