DatabaseConfig: Implement Arrayable contract

This commit is contained in:
Franz Liedke 2019-02-01 13:00:07 +01:00
parent 4baf5d5008
commit d27a9a6421
5 changed files with 9 additions and 7 deletions

View File

@ -11,7 +11,9 @@
namespace Flarum\Install;
class DatabaseConfig
use Illuminate\Contracts\Support\Arrayable;
class DatabaseConfig implements Arrayable
{
private $driver;
private $host;
@ -34,7 +36,7 @@ class DatabaseConfig
$this->validate();
}
public function getConfig(): array
public function toArray()
{
return [
'driver' => $this->driver,

View File

@ -35,7 +35,7 @@ class ConnectToDatabase implements Step
public function run()
{
$config = $this->dbConfig->getConfig();
$config = $this->dbConfig->toArray();
$pdo = (new MySqlConnector)->connect($config);
$version = $pdo->query('SELECT VERSION()')->fetchColumn();

View File

@ -56,7 +56,7 @@ class StoreConfig implements Step, ReversibleStep
{
return [
'debug' => $this->debugMode,
'database' => $this->dbConfig->getConfig(),
'database' => $this->dbConfig->toArray(),
'url' => $this->baseUrl,
'paths' => $this->getPathsConfig(),
];

View File

@ -52,7 +52,7 @@ class DefaultInstallationTest extends TestCase
{
$factory = new ConnectionFactory(app());
return $factory->make($this->getDatabaseConfiguration()->getConfig());
return $factory->make($this->getDatabaseConfiguration()->toArray());
}
private function getAdmin(): AdminUser

View File

@ -107,7 +107,7 @@ trait CreatesForum
{
return [
'debug' => true,
'database' => $this->getDatabaseConfiguration()->getConfig(),
'database' => $this->getDatabaseConfiguration()->toArray(),
'url' => 'http://flarum.local',
'paths' => [
'api' => 'api',
@ -122,7 +122,7 @@ trait CreatesForum
return;
}
$dbConfig = $this->getDatabaseConfiguration()->getConfig();
$dbConfig = $this->getDatabaseConfiguration()->toArray();
$pdo = (new MySqlConnector)->connect($dbConfig);
$db = new MySqlConnection($pdo, $dbConfig['database'], $dbConfig['prefix'], $dbConfig);