Skip to content

Commit

Permalink
Dedup initialize Roundcube environment
Browse files Browse the repository at this point in the history
  • Loading branch information
mvorisek committed Apr 20, 2024
1 parent 8c74725 commit ee7f798
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions src/ExtensionInstaller.php
Original file line number Diff line number Diff line change
Expand Up @@ -61,16 +61,19 @@ public function getInstallPath(PackageInterface $package)
. str_replace('/', \DIRECTORY_SEPARATOR, $this->getPackageName($package));
}

public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
private function initializeRoundcubemailEnvironment(): void
{
$this->setRoundcubemailInstallPath($repo);

// initialize Roundcube environment
if (!defined('INSTALL_PATH')) {
define('INSTALL_PATH', $this->getRoundcubemailInstallPath() . '/');
}
require_once INSTALL_PATH . 'program/include/iniset.php';
}

public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
{
$this->setRoundcubemailInstallPath($repo);
$this->initializeRoundcubemailEnvironment();
$this->rcubeVersionCheck($package);

$postInstall = function () use ($package) {
Expand Down Expand Up @@ -136,13 +139,7 @@ public function install(InstalledRepositoryInterface $repo, PackageInterface $pa
public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
{
$this->setRoundcubemailInstallPath($repo);

// initialize Roundcube environment
if (!defined('INSTALL_PATH')) {
define('INSTALL_PATH', $this->getRoundcubemailInstallPath() . '/');
}
require_once INSTALL_PATH . 'program/include/iniset.php';

$this->initializeRoundcubemailEnvironment();
$this->rcubeVersionCheck($target);

$extra = $target->getExtra();
Expand Down Expand Up @@ -212,12 +209,7 @@ public function update(InstalledRepositoryInterface $repo, PackageInterface $ini
public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
{
$this->setRoundcubemailInstallPath($repo);

// initialize Roundcube environment
if (!defined('INSTALL_PATH')) {
define('INSTALL_PATH', $this->getRoundcubemailInstallPath() . '/');
}
require_once INSTALL_PATH . 'program/include/iniset.php';
$this->initializeRoundcubemailEnvironment();

$config = $this->composer->getConfig()->get('roundcube');

Expand Down

0 comments on commit ee7f798

Please sign in to comment.