summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorMorris Jobke <hey@morrisjobke.de>2017-11-24 10:27:58 +0100
committerMorris Jobke <hey@morrisjobke.de>2017-11-25 12:00:57 +0100
commit0e2f00ec59424b2ef5708a928856e2c75abe6deb (patch)
treecbd61c976a34b352bb8377899a244b66ff82f40d /lib
parenta97a290fd5ed06dfc33d2adeed5d3b7531674827 (diff)
downloadnextcloud-server-0e2f00ec59424b2ef5708a928856e2c75abe6deb.tar.gz
nextcloud-server-0e2f00ec59424b2ef5708a928856e2c75abe6deb.zip
Get the Installer via DI
Signed-off-by: Morris Jobke <hey@morrisjobke.de>
Diffstat (limited to 'lib')
-rw-r--r--lib/base.php12
-rw-r--r--lib/private/Server.php10
-rw-r--r--lib/private/Setup.php28
-rw-r--r--lib/private/Updater.php17
-rw-r--r--lib/private/legacy/app.php16
-rw-r--r--lib/private/legacy/util.php11
6 files changed, 54 insertions, 40 deletions
diff --git a/lib/base.php b/lib/base.php
index dc09d0f533d..30f80695680 100644
--- a/lib/base.php
+++ b/lib/base.php
@@ -915,9 +915,15 @@ class OC {
// Check if Nextcloud is installed or in maintenance (update) mode
if (!$systemConfig->getValue('installed', false)) {
\OC::$server->getSession()->clear();
- $setupHelper = new OC\Setup(\OC::$server->getSystemConfig(), \OC::$server->getIniWrapper(),
- \OC::$server->getL10N('lib'), \OC::$server->query(\OCP\Defaults::class), \OC::$server->getLogger(),
- \OC::$server->getSecureRandom());
+ $setupHelper = new OC\Setup(
+ \OC::$server->getSystemConfig(),
+ \OC::$server->getIniWrapper(),
+ \OC::$server->getL10N('lib'),
+ \OC::$server->query(\OCP\Defaults::class),
+ \OC::$server->getLogger(),
+ \OC::$server->getSecureRandom(),
+ \OC::$server->query(\OC\Installer::class)
+ );
$controller = new OC\Core\Controller\SetupController($setupHelper);
$controller->run($_POST);
exit();
diff --git a/lib/private/Server.php b/lib/private/Server.php
index faa0ce2f2ac..0c6338f6a4c 100644
--- a/lib/private/Server.php
+++ b/lib/private/Server.php
@@ -1099,6 +1099,16 @@ class Server extends ServerContainer implements IServerContainer {
$c->query(\OCP\Share\IManager::class)
);
});
+
+ $this->registerService(Installer::class, function(Server $c) {
+ return new Installer(
+ $c->getAppFetcher(),
+ $c->getHTTPClientService(),
+ $c->getTempManager(),
+ $c->getLogger(),
+ $c->getConfig()
+ );
+ });
}
/**
diff --git a/lib/private/Setup.php b/lib/private/Setup.php
index 8214db2d4ef..92246e8322e 100644
--- a/lib/private/Setup.php
+++ b/lib/private/Setup.php
@@ -65,6 +65,8 @@ class Setup {
protected $logger;
/** @var ISecureRandom */
protected $random;
+ /** @var Installer */
+ protected $installer;
/**
* @param SystemConfig $config
@@ -73,13 +75,15 @@ class Setup {
* @param Defaults $defaults
* @param ILogger $logger
* @param ISecureRandom $random
+ * @param Installer $installer
*/
public function __construct(SystemConfig $config,
IniGetWrapper $iniWrapper,
IL10N $l10n,
Defaults $defaults,
ILogger $logger,
- ISecureRandom $random
+ ISecureRandom $random,
+ Installer $installer
) {
$this->config = $config;
$this->iniWrapper = $iniWrapper;
@@ -87,6 +91,7 @@ class Setup {
$this->defaults = $defaults;
$this->logger = $logger;
$this->random = $random;
+ $this->installer = $installer;
}
static protected $dbSetupClasses = [
@@ -371,18 +376,11 @@ class Setup {
// Install shipped apps and specified app bundles
Installer::installShippedApps();
- $installer = new Installer(
- \OC::$server->getAppFetcher(),
- \OC::$server->getHTTPClientService(),
- \OC::$server->getTempManager(),
- \OC::$server->getLogger(),
- \OC::$server->getConfig()
- );
$bundleFetcher = new BundleFetcher(\OC::$server->getL10N('lib'));
$defaultInstallationBundles = $bundleFetcher->getDefaultInstallationBundle();
foreach($defaultInstallationBundles as $bundle) {
try {
- $installer->installAppBundle($bundle);
+ $this->installer->installAppBundle($bundle);
} catch (Exception $e) {}
}
@@ -444,9 +442,15 @@ class Setup {
$webRoot = !empty(\OC::$WEBROOT) ? \OC::$WEBROOT : '/';
}
- $setupHelper = new \OC\Setup($config, \OC::$server->getIniWrapper(),
- \OC::$server->getL10N('lib'), \OC::$server->query(Defaults::class), \OC::$server->getLogger(),
- \OC::$server->getSecureRandom());
+ $setupHelper = new \OC\Setup(
+ $config,
+ \OC::$server->getIniWrapper(),
+ \OC::$server->getL10N('lib'),
+ \OC::$server->query(Defaults::class),
+ \OC::$server->getLogger(),
+ \OC::$server->getSecureRandom(),
+ \OC::$server->query(Installer::class)
+ );
$htaccessContent = file_get_contents($setupHelper->pathToHtaccess());
$content = "#### DO NOT CHANGE ANYTHING ABOVE THIS LINE ####\n";
diff --git a/lib/private/Updater.php b/lib/private/Updater.php
index 4f5bb45ae15..5c8d5a2cd4e 100644
--- a/lib/private/Updater.php
+++ b/lib/private/Updater.php
@@ -63,6 +63,9 @@ class Updater extends BasicEmitter {
/** @var Checker */
private $checker;
+ /** @var Installer */
+ private $installer;
+
/** @var bool */
private $skip3rdPartyAppsDisable;
@@ -78,13 +81,16 @@ class Updater extends BasicEmitter {
* @param IConfig $config
* @param Checker $checker
* @param ILogger $log
+ * @param Installer $installer
*/
public function __construct(IConfig $config,
Checker $checker,
- ILogger $log = null) {
+ ILogger $log = null,
+ Installer $installer) {
$this->log = $log;
$this->config = $config;
$this->checker = $checker;
+ $this->installer = $installer;
// If at least PHP 7.0.0 is used we don't need to disable apps as we catch
// fatal errors and exceptions and disable the app just instead.
@@ -461,17 +467,10 @@ class Updater extends BasicEmitter {
private function upgradeAppStoreApps(array $disabledApps) {
foreach($disabledApps as $app) {
try {
- $installer = new Installer(
- \OC::$server->getAppFetcher(),
- \OC::$server->getHTTPClientService(),
- \OC::$server->getTempManager(),
- $this->log,
- \OC::$server->getConfig()
- );
$this->emit('\OC\Updater', 'checkAppStoreAppBefore', [$app]);
if (Installer::isUpdateAvailable($app, \OC::$server->getAppFetcher())) {
$this->emit('\OC\Updater', 'upgradeAppStoreApp', [$app]);
- $installer->updateAppstoreApp($app);
+ $this->installer->updateAppstoreApp($app);
}
$this->emit('\OC\Updater', 'checkAppStoreApp', [$app]);
} catch (\Exception $ex) {
diff --git a/lib/private/legacy/app.php b/lib/private/legacy/app.php
index d2b0f96d593..1b9fc28873e 100644
--- a/lib/private/legacy/app.php
+++ b/lib/private/legacy/app.php
@@ -375,13 +375,7 @@ class OC_App {
self::$enabledAppsCache = []; // flush
// Check if app is already downloaded
- $installer = new Installer(
- \OC::$server->getAppFetcher(),
- \OC::$server->getHTTPClientService(),
- \OC::$server->getTempManager(),
- \OC::$server->getLogger(),
- \OC::$server->getConfig()
- );
+ $installer = \OC::$server->query(Installer::class);
$isDownloaded = $installer->isDownloaded($appId);
if(!$isDownloaded) {
@@ -415,13 +409,7 @@ class OC_App {
return false;
}
- $installer = new Installer(
- \OC::$server->getAppFetcher(),
- \OC::$server->getHTTPClientService(),
- \OC::$server->getTempManager(),
- \OC::$server->getLogger(),
- \OC::$server->getConfig()
- );
+ $installer = \OC::$server->query(Installer::class);
return $installer->removeApp($app);
}
diff --git a/lib/private/legacy/util.php b/lib/private/legacy/util.php
index 1e9090960c1..3ce11746672 100644
--- a/lib/private/legacy/util.php
+++ b/lib/private/legacy/util.php
@@ -708,8 +708,15 @@ class OC_Util {
}
$webServerRestart = false;
- $setup = new \OC\Setup($config, \OC::$server->getIniWrapper(), \OC::$server->getL10N('lib'),
- \OC::$server->query(\OCP\Defaults::class), \OC::$server->getLogger(), \OC::$server->getSecureRandom());
+ $setup = new \OC\Setup(
+ $config,
+ \OC::$server->getIniWrapper(),
+ \OC::$server->getL10N('lib'),
+ \OC::$server->query(\OCP\Defaults::class),
+ \OC::$server->getLogger(),
+ \OC::$server->getSecureRandom(),
+ \OC::$server->query(\OC\Installer::class)
+ );
$urlGenerator = \OC::$server->getURLGenerator();