From 4c42be1362cceee89d9c044274233e31e60b307c Mon Sep 17 00:00:00 2001 From: Toby Zerner Date: Sat, 2 May 2015 08:07:51 +0930 Subject: [PATCH] Extract config into database --- framework/core/src/Console/SeedCommand.php | 3 +++ .../core/src/Core/Seeders/ConfigTableSeeder.php | 13 ++++++++++++- framework/core/src/Forum/Actions/IndexAction.php | 8 ++------ framework/core/views/forum.blade.php | 2 +- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/framework/core/src/Console/SeedCommand.php b/framework/core/src/Console/SeedCommand.php index 7f20887fa..97e40ec60 100644 --- a/framework/core/src/Console/SeedCommand.php +++ b/framework/core/src/Console/SeedCommand.php @@ -40,8 +40,11 @@ class SeedCommand extends Command { */ public function fire() { + $this->call('db:seed', ['--class' => 'Flarum\Core\Seeders\GroupsTableSeeder']); + $this->call('db:seed', ['--class' => 'Flarum\Core\Seeders\PermissionsTableSeeder']); $this->call('db:seed', ['--class' => 'Flarum\Core\Seeders\UsersTableSeeder']); $this->call('db:seed', ['--class' => 'Flarum\Core\Seeders\DiscussionsTableSeeder']); + $this->call('db:seed', ['--class' => 'Flarum\Core\Seeders\ConfigTableSeeder']); } /** diff --git a/framework/core/src/Core/Seeders/ConfigTableSeeder.php b/framework/core/src/Core/Seeders/ConfigTableSeeder.php index 5404d7690..dd829ce8b 100644 --- a/framework/core/src/Core/Seeders/ConfigTableSeeder.php +++ b/framework/core/src/Core/Seeders/ConfigTableSeeder.php @@ -1,6 +1,7 @@ 'http://flarum.dev/api', + 'base_url' => 'http://flarum.dev', + 'forum_title' => 'Flarum Demo Forum', + 'welcome_message' => 'Flarum is now at a point where you can have basic conversations, so here is a little demo for you to break.', + 'welcome_title' => 'Welcome to Flarum Demo Forum' + ]; + + DB::table('config')->insert(array_map(function($key, $value) { + return compact('key', 'value'); + }, array_keys($config), $config)); } } diff --git a/framework/core/src/Forum/Actions/IndexAction.php b/framework/core/src/Forum/Actions/IndexAction.php index 9e28b6d06..2671b7d2b 100644 --- a/framework/core/src/Forum/Actions/IndexAction.php +++ b/framework/core/src/Forum/Actions/IndexAction.php @@ -6,17 +6,13 @@ use Auth; use Cookie; use Config; use View; +use DB; class IndexAction extends BaseAction { public function handle(Request $request, $params = []) { - $config = [ - 'baseURL' => 'http://flarum.dev', - 'apiURL' => 'http://flarum.dev/api', - 'forumTitle' => Config::get('flarum::forum_title', 'Flarum Demo Forum'), - 'welcomeDescription' => 'Flarum is now at a point where you can have basic conversations, so here is a little demo for you to break. Learn more »' - ]; + $config = DB::table('config')->whereIn('key', ['base_url', 'api_url', 'forum_title', 'welcome_title', 'welcome_message'])->lists('value', 'key'); $data = []; $session = []; $alert = Session::get('alert'); diff --git a/framework/core/views/forum.blade.php b/framework/core/views/forum.blade.php index 6f6b2e289..fdb2ce2a7 100644 --- a/framework/core/views/forum.blade.php +++ b/framework/core/views/forum.blade.php @@ -4,7 +4,7 @@