/**
* Installation abort method
*
* @param string $msg Abort message from the installer
* @param string $type Package type if defined
*
* @return boolean True if successful
*
* @since 3.1
*/
public function abort($msg = null, $type = null)
{
$retval = true;
$step = array_pop($this->stepStack);
// Raise abort warning
if ($msg) {
Log::add($msg, Log::WARNING, 'jerror');
}
while ($step != null) {
switch ($step['type']) {
case 'file':
// Remove the file
$stepval = File::delete($step['path']);
break;
case 'folder':
// Remove the folder
$stepval = Folder::delete($step['path']);
break;
case 'query':
// Execute the query.
$stepval = $this->parseSQLFiles($step['script']);
break;
case 'extension':
// Get database connector object
$db = $this->getDbo();
$query = $db->getQuery(true);
$stepId = (int) $step['id'];
// Remove the entry from the #__extensions table
$query->delete($db->quoteName('#__extensions'))->where($db->quoteName('extension_id') . ' = :step_id')->bind(':step_id', $stepId, ParameterType::INTEGER);
$db->setQuery($query);
try {
$db->execute();
$stepval = true;
} catch (ExecutionFailureException $e) {
// The database API will have already logged the error it caught, we just need to alert the user to the issue
Log::add(Text::_('JLIB_INSTALLER_ABORT_ERROR_DELETING_EXTENSIONS_RECORD'), Log::WARNING, 'jerror');
$stepval = false;
}
break;
default:
if ($type && \is_object($this->_adapters[$type])) {
// Build the name of the custom rollback method for the type
$method = '_rollback_' . $step['type'];
// Custom rollback method handler
if (method_exists($this->_adapters[$type], $method)) {
$stepval = $this->_adapters[$type]->{$method}($step);
}
} else {
// Set it to false
$stepval = false;
}
break;
}
// Only set the return value if it is false
if ($stepval === false) {
$retval = false;
}
// Get the next step and continue
$step = array_pop($this->stepStack);
}
return $retval;
}