Back to Versioning class

Method get

public static object[]
get
(mixed $typeAlias, mixed $id)
Method to get a list of available versions of this item.
Parameters
  • string $typeAlias Typealias of the component
  • int $id ID of the content item to get
Returns
  • object[] A list of history items
Since
  • 4.0.0
Class: Versioning
Project: Joomla

Method get - Source code

/**
 * Method to get a list of available versions of this item.
 *
 * @param   string   $typeAlias  Typealias of the component
 * @param   integer  $id         ID of the content item to get
 *
 * @return  object[]   A list of history items
 *
 * @since   4.0.0
 */
public static function get($typeAlias, $id)
{
    $db = Factory::getDbo();
    $itemid = $typeAlias . '.' . $id;
    $query = $db->getQuery(true);
    $query->select($db->quoteName('h.version_note') . ',' . $db->quoteName('h.save_date') . ',' . $db->quoteName('u.name'))->from($db->quoteName('#__history', 'h'))->leftJoin($db->quoteName('#__users', 'u'), $db->quoteName('u.id') . ' = ' . $db->quoteName('h.editor_user_id'))->where($db->quoteName('item_id') . ' = :item_id')->bind(':item_id', $itemid, ParameterType::STRING)->order($db->quoteName('save_date') . ' DESC ');
    $db->setQuery($query);
    return $db->loadObjectList();
}