]> git.mxchange.org Git - friendica.git/blobdiff - src/Console/AutomaticInstallation.php
Creating interfaces for Config/PConfig & fix tests
[friendica.git] / src / Console / AutomaticInstallation.php
index 0f1e7a742f1864e191a75cd73144020f400fb21d..1d378b9debaca75961884c559e458fc63f9a08d7 100644 (file)
@@ -25,7 +25,7 @@ class AutomaticInstallation extends Console
        private $configCache;
 
        /**
-        * @var Config\Configuration
+        * @var Config\IConfiguration
         */
        private $config;
 
@@ -89,7 +89,7 @@ Examples
 HELP;
        }
 
-       public function __construct(App\Mode $appMode, Config\Cache\ConfigCache $configCache, Config\Configuration $config, Database $dba, array $argv = null)
+       public function __construct(App\Mode $appMode, Config\Cache\ConfigCache $configCache, Config\IConfiguration $config, Database $dba, array $argv = null)
        {
                parent::__construct($argv);
 
@@ -129,16 +129,13 @@ HELP;
                $config_file = $this->getOption(['f', 'file']);
 
                if (!empty($config_file)) {
-                       if ($config_file != 'config' . DIRECTORY_SEPARATOR . 'local.config.php') {
-                               // Copy config file
-                               $this->out("Copying config file...\n");
-                               if (!copy($basePathConf . DIRECTORY_SEPARATOR . $config_file, $basePathConf . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'local.config.php')) {
-                                       throw new RuntimeException("ERROR: Saving config file failed. Please copy '$config_file' to '" . $basePathConf . "'" . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . "local.config.php' manually.\n");
-                               }
+
+                       if (!file_exists($config_file)) {
+                               throw new RuntimeException("ERROR: Config file does not exist.\n");
                        }
 
                        //reload the config cache
-                       $loader = new ConfigFileLoader($basePathConf);
+                       $loader = new ConfigFileLoader($config_file);
                        $loader->setupCache($configCache);
 
                } else {
@@ -195,7 +192,7 @@ HELP;
                        $installer->createConfig($configCache);
                }
 
-               $this->out(" Complete!\n\n");
+               $this->out("Complete!\n\n");
 
                // Check database connection
                $this->out("Checking database...\n");
@@ -219,6 +216,14 @@ HELP;
                        throw new RuntimeException($errorMessage);
                }
 
+               if (!empty($config_file) && $config_file != 'config' . DIRECTORY_SEPARATOR . 'local.config.php') {
+                       // Copy config file
+                       $this->out("Copying config file...\n");
+                       if (!copy($basePathConf . DIRECTORY_SEPARATOR . $config_file, $basePathConf . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'local.config.php')) {
+                               throw new RuntimeException("ERROR: Saving config file failed. Please copy '$config_file' to '" . $basePathConf . "'" . DIRECTORY_SEPARATOR . "config" . DIRECTORY_SEPARATOR . "local.config.php' manually.\n");
+                       }
+               }
+
                $this->out(" Complete!\n\n");
 
                // Install theme