/**
* Executes a custom install script method
*
* @param string $method The install method to execute
*
* @return boolean True on success
*
* @since 3.4
* @throws \RuntimeException
*/
protected function triggerManifestScript($method)
{
ob_start();
ob_implicit_flush(false);
if ($this->parent->manifestClass && method_exists($this->parent->manifestClass, $method)) {
switch ($method) {
// The preflight and postflight take the route as a param
case 'preflight':
case 'postflight':
if ($this->parent->manifestClass->{$method}($this->route, $this) === false) {
if ($method !== 'postflight') {
// Clean and close the output buffer
ob_end_clean();
// The script failed, rollback changes
throw new \RuntimeException(Text::sprintf('JLIB_INSTALLER_ABORT_INSTALL_CUSTOM_INSTALL_FAILURE', Text::_('JLIB_INSTALLER_' . $this->route)));
}
}
break;
// The install, uninstall, and update methods only pass this object as a param
case 'install':
case 'uninstall':
case 'update':
if ($this->parent->manifestClass->{$method}($this) === false) {
if ($method !== 'uninstall') {
// Clean and close the output buffer
ob_end_clean();
// The script failed, rollback changes
throw new \RuntimeException(Text::sprintf('JLIB_INSTALLER_ABORT_INSTALL_CUSTOM_INSTALL_FAILURE', Text::_('JLIB_INSTALLER_' . $this->route)));
}
}
break;
}
}
// Append to the message object
$this->extensionMessage .= ob_get_clean();
// If in postflight or uninstall, set the message for display
if (($method === 'uninstall' || $method === 'postflight') && $this->extensionMessage !== '') {
$this->parent->set('extension_message', $this->extensionMessage);
}
return true;
}