public function cancel($key = null)
{
$this->checkToken();
$model = $this->getModel();
$table = $model->getTable();
$context = "{$this->option}.edit.{$this->context}";
if (empty($key)) {
$key = $table->getKeyName();
}
$recordId = $this->input->getInt($key);
if ($recordId && $table->hasField('checked_out') && $model->checkin($recordId) === false) {
$this->setMessage(Text::sprintf('JLIB_APPLICATION_ERROR_CHECKIN_FAILED', $model->getError()), 'error');
$this->setRedirect(Route::_('index.php?option=' . $this->option . '&view=' . $this->view_item . $this->getRedirectToItemAppend($recordId, $key), false));
return false;
}
$this->releaseEditId($context, $recordId);
Factory::getApplication()->setUserState($context . '.data', null);
$url = 'index.php?option=' . $this->option . '&view=' . $this->view_list . $this->getRedirectToListAppend();
$return = $this->input->get('return', null, 'base64');
if (!\is_null($return) && Uri::isInternal(base64_decode($return))) {
$url = base64_decode($return);
}
$this->setRedirect(Route::_($url, false));
return true;
}