I found by Joomla 3.x, that I can use an install script something like this:
class lib_exampleInstallerScript
{
public function install($adapter)
{
// during install
}
public function uninstall($adapter)
{
// during uninstall
}
public function update($adapter)
{
// during update
}
public function preflight($route, $adapter)
{
// before all
}
public function postflight($route, $adapter)
{
// after all
}
}
I was trying to create a script that verifies if the current extensions to be installed have higher version than the installed on system. Something like this:
public function preflight($type, $parent){
// Return true if version to be installed is higher
if (!$this->isHigherVersion($parent)){
$msg = "<p>Error msg.</p>";
JLog::add($msg, JLog::WARNING, 'jerror');
return false;
}
}
However, it seems that before getting into the preflight, joomla deletes the contents of the folder in the installed extension, and as I stop the process in the preflight, I get a folder without the files, just the installation script. This shoul work when extension will installed or updated.