- md5
- d358023fcf0b9c2e0f0465ff92cae850
- sha1
- 8dbde3c3bd71cbdbd53699d4fec36b1773f3ebb8
- sha256
- 48e5e98f13bcb84cfd63677eb5600173352df8979de4ac9080a1272fd4c63f82
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
<?php
/**
* Joomla! Content Management System
*
* @copyright (C) 2019 Open Source Matters, Inc. <https://www.joomla.org>
* @license GNU General Public License version 2 or later; see LICENSE.txt
*/
namespace Joomla\CMS\Versioning;
\defined('JPATH_PLATFORM') or die;
use Joomla\CMS\Table\Table;
use Joomla\Utilities\ArrayHelper;
/**
* Defines the trait for a Versionable Model Class.
*
* @since 3.10.0
*/
trait VersionableModelTrait
{
/**
* Method to load a row for editing from the version history table.
*
* @param integer $versionId Key to the version history table.
* @param Table $table Content table object being loaded.
*
* @return boolean False on failure or error, true otherwise.
*
* @since 4.0.0
*/
public function loadHistory($versionId, Table &$table)
{
// Only attempt to check the row in if it exists, otherwise do an early exit.
if (!$versionId)
{
return false;
}
// Get an instance of the row to checkout.
$historyTable = Table::getInstance('Contenthistory');
if (!$historyTable->load($versionId))
{
$this->setError($historyTable->getError());
return false;
}
$typeAlias = explode('.', $historyTable->item_id);
array_pop($typeAlias);
$rowArray = ArrayHelper::fromObject(json_decode($historyTable->version_data));
if (implode('.', $typeAlias) != $this->typeAlias)
{
$this->setError(Text::_('JLIB_APPLICATION_ERROR_HISTORY_ID_MISMATCH'));
$key = $table->getKeyName();
if (isset($rowArray[$key]))
{
$table->checkIn($rowArray[$key]);
}
return false;
}
$this->setState('save_date', $historyTable->save_date);
$this->setState('version_note', $historyTable->version_note);
return $table->bind($rowArray);
}
}
The same content is in 2 releases, Joomla 4.0.0-beta6 to 4.0.0-beta7. See them all, or every version of this file.