diff --git a/framework/core/src/Install/Installation.php b/framework/core/src/Install/Installation.php index bc703db7c..e18347143 100644 --- a/framework/core/src/Install/Installation.php +++ b/framework/core/src/Install/Installation.php @@ -102,15 +102,6 @@ class Installation // It's an instance variable so that access in closures is easier. :) $this->tmp = []; - $pipeline->pipe(function () { - return new Steps\BuildConfig( - $this->debug, $this->dbConfig, $this->baseUrl, - function ($config) { - $this->tmp['config'] = $config; - } - ); - }); - $pipeline->pipe(function () { return new Steps\ConnectToDatabase( $this->dbConfig, @@ -121,7 +112,9 @@ class Installation }); $pipeline->pipe(function () { - return new Steps\StoreConfig($this->tmp['config'], $this->getConfigPath()); + return new Steps\StoreConfig( + $this->debug, $this->dbConfig, $this->baseUrl, $this->getConfigPath() + ); }); $pipeline->pipe(function () { diff --git a/framework/core/src/Install/Steps/BuildConfig.php b/framework/core/src/Install/Steps/BuildConfig.php deleted file mode 100644 index bab1a160e..000000000 --- a/framework/core/src/Install/Steps/BuildConfig.php +++ /dev/null @@ -1,75 +0,0 @@ - - * - * For the full copyright and license information, please view the LICENSE - * file that was distributed with this source code. - */ - -namespace Flarum\Install\Steps; - -use Flarum\Install\Step; - -class BuildConfig implements Step -{ - private $debugMode; - - private $dbConfig; - - private $baseUrl; - - private $store; - - public function __construct($debugMode, $dbConfig, $baseUrl, callable $store) - { - $this->debugMode = $debugMode; - $this->dbConfig = $dbConfig; - $this->baseUrl = $baseUrl; - - $this->store = $store; - } - - public function getMessage() - { - return 'Building config array'; - } - - public function run() - { - $config = [ - 'debug' => $this->debugMode, - 'database' => $this->getDatabaseConfig(), - 'url' => $this->baseUrl, - 'paths' => $this->getPathsConfig(), - ]; - - ($this->store)($config); - } - - private function getDatabaseConfig() - { - return [ - 'driver' => $this->dbConfig['driver'], - 'host' => $this->dbConfig['host'], - 'database' => $this->dbConfig['database'], - 'username' => $this->dbConfig['username'], - 'password' => $this->dbConfig['password'], - 'charset' => 'utf8mb4', - 'collation' => 'utf8mb4_unicode_ci', - 'prefix' => $this->dbConfig['prefix'], - 'port' => $this->dbConfig['port'], - 'strict' => false, - ]; - } - - private function getPathsConfig() - { - return [ - 'api' => 'api', - 'admin' => 'admin', - ]; - } -} diff --git a/framework/core/src/Install/Steps/StoreConfig.php b/framework/core/src/Install/Steps/StoreConfig.php index f2c2a22f3..fca897ff4 100644 --- a/framework/core/src/Install/Steps/StoreConfig.php +++ b/framework/core/src/Install/Steps/StoreConfig.php @@ -16,13 +16,20 @@ use Flarum\Install\Step; class StoreConfig implements Step, ReversibleStep { - private $config; + private $debugMode; + + private $dbConfig; + + private $baseUrl; private $configFile; - public function __construct(array $config, $configFile) + public function __construct($debugMode, $dbConfig, $baseUrl, $configFile) { - $this->config = $config; + $this->debugMode = $debugMode; + $this->dbConfig = $dbConfig; + $this->baseUrl = $baseUrl; + $this->configFile = $configFile; } @@ -35,7 +42,7 @@ class StoreConfig implements Step, ReversibleStep { file_put_contents( $this->configFile, - 'config, true).';' + 'buildConfig(), true).';' ); } @@ -43,4 +50,38 @@ class StoreConfig implements Step, ReversibleStep { @unlink($this->configFile); } + + private function buildConfig() + { + return [ + 'debug' => $this->debugMode, + 'database' => $this->getDatabaseConfig(), + 'url' => $this->baseUrl, + 'paths' => $this->getPathsConfig(), + ]; + } + + private function getDatabaseConfig() + { + return [ + 'driver' => $this->dbConfig['driver'], + 'host' => $this->dbConfig['host'], + 'database' => $this->dbConfig['database'], + 'username' => $this->dbConfig['username'], + 'password' => $this->dbConfig['password'], + 'charset' => 'utf8mb4', + 'collation' => 'utf8mb4_unicode_ci', + 'prefix' => $this->dbConfig['prefix'], + 'port' => $this->dbConfig['port'], + 'strict' => false, + ]; + } + + private function getPathsConfig() + { + return [ + 'api' => 'api', + 'admin' => 'admin', + ]; + } }