/** * Tries to install or update FOF. The FOF library package installation can fail if there's a newer version * installed. In this case we raise no error. If, however, the FOF library package installation failed AND we can * not load FOF then we raise an error: this means that FOF installation really failed (e.g. unwritable folder) and * we can't install this package. * * @param \JInstallerAdapterPackage $parent */ private function installOrUpdateFOF($parent) { // Get the path to the FOF package $sourcePath = $parent->getParent()->getPath('source'); $sourcePackage = $sourcePath . '/lib_fof30.zip'; // Extract and install the package $package = JInstallerHelper::unpack($sourcePackage); $tmpInstaller = new JInstaller(); $error = null; try { $installResult = $tmpInstaller->install($package['dir']); } catch (\Exception $e) { $installResult = false; $error = $e->getMessage(); } // Try to include FOF. If that fails then the FOF package isn't installed because its installation failed, not // because we had a newer version already installed. As a result we have to abort the entire package's // installation. if (!defined('FOF30_INCLUDED') && !@(include_once JPATH_LIBRARIES . '/fof30/include.php')) { if (empty($error)) { $error = JText::sprintf('JLIB_INSTALLER_ABORT_PACK_INSTALL_ERROR_EXTENSION', JText::_('JLIB_INSTALLER_' . strtoupper($parent->get('route'))), basename($sourcePackage)); } throw new RuntimeException($error); } }