mirror of
https://github.com/flarum/framework.git
synced 2024-12-03 15:43:59 +08:00
DatabaseConfig: Implement Arrayable contract
This commit is contained in:
parent
4baf5d5008
commit
d27a9a6421
|
@ -11,7 +11,9 @@
|
||||||
|
|
||||||
namespace Flarum\Install;
|
namespace Flarum\Install;
|
||||||
|
|
||||||
class DatabaseConfig
|
use Illuminate\Contracts\Support\Arrayable;
|
||||||
|
|
||||||
|
class DatabaseConfig implements Arrayable
|
||||||
{
|
{
|
||||||
private $driver;
|
private $driver;
|
||||||
private $host;
|
private $host;
|
||||||
|
@ -34,7 +36,7 @@ class DatabaseConfig
|
||||||
$this->validate();
|
$this->validate();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getConfig(): array
|
public function toArray()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'driver' => $this->driver,
|
'driver' => $this->driver,
|
||||||
|
|
|
@ -35,7 +35,7 @@ class ConnectToDatabase implements Step
|
||||||
|
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
$config = $this->dbConfig->getConfig();
|
$config = $this->dbConfig->toArray();
|
||||||
$pdo = (new MySqlConnector)->connect($config);
|
$pdo = (new MySqlConnector)->connect($config);
|
||||||
|
|
||||||
$version = $pdo->query('SELECT VERSION()')->fetchColumn();
|
$version = $pdo->query('SELECT VERSION()')->fetchColumn();
|
||||||
|
|
|
@ -56,7 +56,7 @@ class StoreConfig implements Step, ReversibleStep
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'debug' => $this->debugMode,
|
'debug' => $this->debugMode,
|
||||||
'database' => $this->dbConfig->getConfig(),
|
'database' => $this->dbConfig->toArray(),
|
||||||
'url' => $this->baseUrl,
|
'url' => $this->baseUrl,
|
||||||
'paths' => $this->getPathsConfig(),
|
'paths' => $this->getPathsConfig(),
|
||||||
];
|
];
|
||||||
|
|
|
@ -52,7 +52,7 @@ class DefaultInstallationTest extends TestCase
|
||||||
{
|
{
|
||||||
$factory = new ConnectionFactory(app());
|
$factory = new ConnectionFactory(app());
|
||||||
|
|
||||||
return $factory->make($this->getDatabaseConfiguration()->getConfig());
|
return $factory->make($this->getDatabaseConfiguration()->toArray());
|
||||||
}
|
}
|
||||||
|
|
||||||
private function getAdmin(): AdminUser
|
private function getAdmin(): AdminUser
|
||||||
|
|
|
@ -107,7 +107,7 @@ trait CreatesForum
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'debug' => true,
|
'debug' => true,
|
||||||
'database' => $this->getDatabaseConfiguration()->getConfig(),
|
'database' => $this->getDatabaseConfiguration()->toArray(),
|
||||||
'url' => 'http://flarum.local',
|
'url' => 'http://flarum.local',
|
||||||
'paths' => [
|
'paths' => [
|
||||||
'api' => 'api',
|
'api' => 'api',
|
||||||
|
@ -122,7 +122,7 @@ trait CreatesForum
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
$dbConfig = $this->getDatabaseConfiguration()->getConfig();
|
$dbConfig = $this->getDatabaseConfiguration()->toArray();
|
||||||
|
|
||||||
$pdo = (new MySqlConnector)->connect($dbConfig);
|
$pdo = (new MySqlConnector)->connect($dbConfig);
|
||||||
$db = new MySqlConnection($pdo, $dbConfig['database'], $dbConfig['prefix'], $dbConfig);
|
$db = new MySqlConnection($pdo, $dbConfig['database'], $dbConfig['prefix'], $dbConfig);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user