Skip to content

Commit ee7f798

Browse files
committed
Dedup initialize Roundcube environment
1 parent 8c74725 commit ee7f798

1 file changed

Lines changed: 8 additions & 16 deletions

File tree

src/ExtensionInstaller.php

Lines changed: 8 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -61,16 +61,19 @@ public function getInstallPath(PackageInterface $package)
6161
. str_replace('/', \DIRECTORY_SEPARATOR, $this->getPackageName($package));
6262
}
6363

64-
public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
64+
private function initializeRoundcubemailEnvironment(): void
6565
{
66-
$this->setRoundcubemailInstallPath($repo);
67-
6866
// initialize Roundcube environment
6967
if (!defined('INSTALL_PATH')) {
7068
define('INSTALL_PATH', $this->getRoundcubemailInstallPath() . '/');
7169
}
7270
require_once INSTALL_PATH . 'program/include/iniset.php';
71+
}
7372

73+
public function install(InstalledRepositoryInterface $repo, PackageInterface $package)
74+
{
75+
$this->setRoundcubemailInstallPath($repo);
76+
$this->initializeRoundcubemailEnvironment();
7477
$this->rcubeVersionCheck($package);
7578

7679
$postInstall = function () use ($package) {
@@ -136,13 +139,7 @@ public function install(InstalledRepositoryInterface $repo, PackageInterface $pa
136139
public function update(InstalledRepositoryInterface $repo, PackageInterface $initial, PackageInterface $target)
137140
{
138141
$this->setRoundcubemailInstallPath($repo);
139-
140-
// initialize Roundcube environment
141-
if (!defined('INSTALL_PATH')) {
142-
define('INSTALL_PATH', $this->getRoundcubemailInstallPath() . '/');
143-
}
144-
require_once INSTALL_PATH . 'program/include/iniset.php';
145-
142+
$this->initializeRoundcubemailEnvironment();
146143
$this->rcubeVersionCheck($target);
147144

148145
$extra = $target->getExtra();
@@ -212,12 +209,7 @@ public function update(InstalledRepositoryInterface $repo, PackageInterface $ini
212209
public function uninstall(InstalledRepositoryInterface $repo, PackageInterface $package)
213210
{
214211
$this->setRoundcubemailInstallPath($repo);
215-
216-
// initialize Roundcube environment
217-
if (!defined('INSTALL_PATH')) {
218-
define('INSTALL_PATH', $this->getRoundcubemailInstallPath() . '/');
219-
}
220-
require_once INSTALL_PATH . 'program/include/iniset.php';
212+
$this->initializeRoundcubemailEnvironment();
221213

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

0 commit comments

Comments
 (0)