/**
* Generic discover_install method for extensions
*
* @return boolean True on success
*
* @since 3.4
*/
public function discover_install()
{
// Get the extension's description
$description = (string) $this->getManifest()->description;
if ($description) {
$this->parent->message = Text::_($description);
} else {
$this->parent->message = '';
}
// Set the extension's name and element
$this->name = $this->getName();
$this->element = $this->getElement();
/*
* ---------------------------------------------------------------------------------------------
* Extension Precheck and Setup Section
* ---------------------------------------------------------------------------------------------
*/
// Setup the install paths and perform other prechecks as necessary
try {
$this->setupInstallPaths();
} catch (\RuntimeException $e) {
// Install failed, roll back changes
$this->parent->abort($e->getMessage());
return false;
}
/*
* ---------------------------------------------------------------------------------------------
* Installer Trigger Loading
* ---------------------------------------------------------------------------------------------
*/
$this->setupScriptfile();
try {
$this->triggerManifestScript('preflight');
} catch (\RuntimeException $e) {
// Install failed, roll back changes
$this->parent->abort($e->getMessage());
return false;
}
/*
* ---------------------------------------------------------------------------------------------
* Database Processing Section
* ---------------------------------------------------------------------------------------------
*/
try {
$this->storeExtension();
} catch (\RuntimeException $e) {
// Install failed, roll back changes
$this->parent->abort($e->getMessage());
return false;
}
try {
$this->parseQueries();
} catch (\RuntimeException $e) {
// Install failed, roll back changes
$this->parent->abort($e->getMessage());
return false;
}
// Run the custom install method
try {
$this->triggerManifestScript('install');
} catch (\RuntimeException $e) {
// Install failed, roll back changes
$this->parent->abort($e->getMessage());
return false;
}
/*
* ---------------------------------------------------------------------------------------------
* Finalization and Cleanup Section
* ---------------------------------------------------------------------------------------------
*/
try {
$this->finaliseInstall();
} catch (\RuntimeException $e) {
// Install failed, roll back changes
$this->parent->abort($e->getMessage());
return false;
}
// And now we run the postflight
try {
$this->triggerManifestScript('postflight');
} catch (\RuntimeException $e) {
// Install failed, roll back changes
$this->parent->abort($e->getMessage());
return false;
}
return $this->extension->extension_id;
}