]> git.mxchange.org Git - friendica.git/blobdiff - src/Core/Installer.php
Fix language (again ;-) )
[friendica.git] / src / Core / Installer.php
index 2df398fb0d0af6d4c6f64cca6a5ef069783bc118..de041773ef6b88b7525b7a35cad64ce043e9e798 100644 (file)
@@ -6,12 +6,11 @@ namespace Friendica\Core;
 
 use DOMDocument;
 use Exception;
-use Friendica\Core\Config\Cache\IConfigCache;
-use Friendica\Database\DBA;
+use Friendica\Core\Config\Cache\ConfigCache;
 use Friendica\Database\DBStructure;
+use Friendica\Factory\DBFactory;
 use Friendica\Object\Image;
 use Friendica\Util\Logger\VoidLogger;
-use Friendica\Util\BasePath;
 use Friendica\Util\Network;
 use Friendica\Util\Profiler;
 use Friendica\Util\Strings;
@@ -131,17 +130,15 @@ class Installer
         * - Creates `config/local.config.php`
         * - Installs Database Structure
         *
-        * @param IConfigCache $configCache The config cache with all config relevant information
+        * @param ConfigCache $configCache The config cache with all config relevant information
         *
         * @return bool true if the config was created, otherwise false
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
-       public function createConfig(IConfigCache $configCache)
+       public function createConfig(ConfigCache $configCache)
        {
                $basepath = $configCache->get('system', 'basepath');
 
-               $url = $configCache->get('system', 'url');
-
                $tpl = Renderer::getMarkupTemplate('local.config.tpl');
                $txt = Renderer::replaceMacros($tpl, [
                        '$dbhost'    => $configCache->get('database', 'hostname'),
@@ -154,12 +151,12 @@ class Installer
                        '$hostname'  => $configCache->get('config', 'hostname'),
 
                        '$urlpath'   => $configCache->get('system', 'urlpath'),
-                       '$baseurl'   => $url,
+                       '$baseurl'   => $configCache->get('system', 'url'),
                        '$sslpolicy' => $configCache->get('system', 'ssl_policy'),
                        '$basepath'  => $basepath,
                        '$timezone'  => $configCache->get('system', 'default_timezone'),
                        '$language'  => $configCache->get('system', 'language'),
-               ], false);
+               ]);
 
                $result = file_put_contents($basepath . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'local.config.php', $txt);
 
@@ -595,31 +592,26 @@ class Installer
        /**
         * Checking the Database connection and if it is available for the current installation
         *
-        * @param IConfigCache $configCache The configuration cache
+        * @param ConfigCache $configCache The configuration cache
         * @param Profiler    $profiler    The profiler of this app
         *
         * @return bool true if the check was successful, otherwise false
         * @throws Exception
         */
-       public function checkDB(IConfigCache $configCache, Profiler $profiler)
+       public function checkDB(ConfigCache $configCache, Profiler $profiler)
        {
-               $dbhost = $configCache->get('database', 'hostname');
-               $dbuser = $configCache->get('database', 'username');
-               $dbpass = $configCache->get('database', 'password');
-               $dbdata = $configCache->get('database', 'database');
-
-               if (!DBA::connect($configCache, $profiler, new VoidLogger(), $dbhost, $dbuser, $dbpass, $dbdata)) {
-                       $this->addCheck(L10n::t('Could not connect to database.'), false, true, '');
+               $database = DBFactory::init($configCache, $profiler, [], new VoidLogger());
 
-                       return false;
-               }
-
-               if (DBA::connected()) {
+               if ($database->connected()) {
                        if (DBStructure::existsTable('user')) {
                                $this->addCheck(L10n::t('Database already in use.'), false, true, '');
 
                                return false;
                        }
+               } else {
+                       $this->addCheck(L10n::t('Could not connect to database.'), false, true, '');
+
+                       return false;
                }
 
                return true;
@@ -628,12 +620,12 @@ class Installer
        /**
         * Setup the default cache for a new installation
         *
-        * @param IConfigCache $configCache The configuration cache
+        * @param ConfigCache $configCache The configuration cache
         * @param string       $basePath    The determined basepath
         *
         * @throws \Friendica\Network\HTTPException\InternalServerErrorException
         */
-       public function setUpCache(IConfigCache $configCache, $basePath)
+       public function setUpCache(ConfigCache $configCache, $basePath)
        {
                $configCache->set('config', 'php_path'  , $this->getPHPPath());
                $configCache->set('system', 'basepath'  , $basePath);