/**
* Function called before extension installation/update/removal procedure commences
*
* @param string $type The type of change (install, update or discover_install, not uninstall)
* @param InstallerAdapter $parent The class calling this method
*
* @return boolean True on success
*
* @since 3.6
*/
public function preflight($type, $parent)
{
// Check for the minimum PHP version before continuing
if (!empty($this->minimumPhp) && version_compare(PHP_VERSION, $this->minimumPhp, '<')) {
Log::add(Text::sprintf('JLIB_INSTALLER_MINIMUM_PHP', $this->minimumPhp), Log::WARNING, 'jerror');
return false;
}
// Check for the minimum Joomla version before continuing
if (!empty($this->minimumJoomla) && version_compare(JVERSION, $this->minimumJoomla, '<')) {
Log::add(Text::sprintf('JLIB_INSTALLER_MINIMUM_JOOMLA', $this->minimumJoomla), Log::WARNING, 'jerror');
return false;
}
// Extension manifest file version
$this->extension = $parent->getName();
$this->release = $parent->getManifest()->version;
$extensionType = substr($this->extension, 0, 3);
// Modules parameters are located in the module table - else in the extension table
if ($extensionType === 'mod') {
$this->paramTable = '#__modules';
} else {
$this->paramTable = '#__extensions';
}
// Abort if the extension being installed is not newer than the currently installed version
if (!$this->allowDowngrades && strtolower($type) === 'update') {
$manifest = $this->getItemArray('manifest_cache', '#__extensions', 'element', $this->extension);
// Check whether we have an old release installed and skip this check when this here is the initial install.
if (!isset($manifest['version'])) {
return true;
}
$oldRelease = $manifest['version'];
if (version_compare($this->release, $oldRelease, '<')) {
Factory::getApplication()->enqueueMessage(Text::sprintf('JLIB_INSTALLER_INCORRECT_SEQUENCE', $oldRelease, $this->release), 'error');
return false;
}
}
return true;
}