diff --git a/src/ExtensionInstaller.php b/src/ExtensionInstaller.php index dff6d01..97de463 100644 --- a/src/ExtensionInstaller.php +++ b/src/ExtensionInstaller.php @@ -47,16 +47,17 @@ public function getInstallPath(PackageInterface $package) public function install(InstalledRepositoryInterface $repo, PackageInterface $package) { - // initialize Roundcube environment $this->setRoundcubemailInstallPath($repo); - if (!defined('INSTALL_PATH')) { - define('INSTALL_PATH', $this->getRoundcubemailInstallPath() . '/'); - } - require_once INSTALL_PATH . 'program/include/iniset.php'; - - $this->rcubeVersionCheck($package); $postInstall = function () use ($package) { + // initialize Roundcube environment + if (!defined('INSTALL_PATH')) { + define('INSTALL_PATH', $this->getRoundcubemailInstallPath() . '/'); + } + require_once INSTALL_PATH . 'program/include/iniset.php'; + + $this->rcubeVersionCheck($package); + $config_file = $this->rcubeConfigFile(); $package_name = $this->getPackageName($package); $package_dir = $this->getVendorDir() . \DIRECTORY_SEPARATOR . $package_name; @@ -118,27 +119,28 @@ public function install(InstalledRepositoryInterface $repo, PackageInterface $pa public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target) { - // initialize Roundcube environment $this->setRoundcubemailInstallPath($repo); - if (!defined('INSTALL_PATH')) { - define('INSTALL_PATH', $this->getRoundcubemailInstallPath() . '/'); - } - require_once INSTALL_PATH . 'program/include/iniset.php'; - $this->rcubeVersionCheck($target); + $postUpdate = function () use ($target) { + // initialize Roundcube environment + if (!defined('INSTALL_PATH')) { + define('INSTALL_PATH', $this->getRoundcubemailInstallPath() . '/'); + } + require_once INSTALL_PATH . 'program/include/iniset.php'; - $extra = $target->getExtra(); - $fs = new Filesystem(); + $this->rcubeVersionCheck($target); - // backup persistent files e.g. config.inc.php - $package_name = $this->getPackageName($initial); - $package_dir = $this->getVendorDir() . \DIRECTORY_SEPARATOR . $package_name; - $temp_dir = $package_dir . '-' . sprintf('%010d%010d', mt_rand(), mt_rand()); + $extra = $target->getExtra(); + $fs = new Filesystem(); + + // backup persistent files e.g. config.inc.php + $package_name = $this->getPackageName($initial); + $package_dir = $this->getVendorDir() . \DIRECTORY_SEPARATOR . $package_name; + $temp_dir = $package_dir . '-' . sprintf('%010d%010d', mt_rand(), mt_rand()); - // make a backup of existing files (for restoring persistent files) - $fs->copy($package_dir, $temp_dir); + // make a backup of existing files (for restoring persistent files) + $fs->copy($package_dir, $temp_dir); - $postUpdate = function () use ($target, $extra, $fs, $temp_dir) { $package_name = $this->getPackageName($target); $package_dir = $this->getVendorDir() . \DIRECTORY_SEPARATOR . $package_name; @@ -192,16 +194,17 @@ public function update(InstalledRepositoryInterface $repo, PackageInterface $ini public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package) { - // initialize Roundcube environment $this->setRoundcubemailInstallPath($repo); - if (!defined('INSTALL_PATH')) { - define('INSTALL_PATH', $this->getRoundcubemailInstallPath() . '/'); - } - require_once INSTALL_PATH . 'program/include/iniset.php'; - $config = $this->composer->getConfig()->get('roundcube'); + $postUninstall = function () use ($package) { + // initialize Roundcube environment + if (!defined('INSTALL_PATH')) { + define('INSTALL_PATH', $this->getRoundcubemailInstallPath() . '/'); + } + require_once INSTALL_PATH . 'program/include/iniset.php'; + + $config = $this->composer->getConfig()->get('roundcube'); - $postUninstall = function () use ($package, $config) { // post-uninstall: deactivate package $package_name = $this->getPackageName($package); $package_dir = $this->getVendorDir() . \DIRECTORY_SEPARATOR . $package_name;