mirror of
https://github.com/flarum/framework.git
synced 2024-12-12 06:03:39 +08:00
Get rid of more facade usage
This commit is contained in:
parent
caf8e29852
commit
d27526431c
|
@ -15,7 +15,7 @@ class Core
|
||||||
return $default;
|
return $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (is_null($value = DB::table('config')->where('key', $key)->pluck('value'))) {
|
if (is_null($value = app('db')->table('config')->where('key', $key)->pluck('value'))) {
|
||||||
$value = $default;
|
$value = $default;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,9 +5,9 @@ use Flarum\Core;
|
||||||
use Flarum\Support\Actor;
|
use Flarum\Support\Actor;
|
||||||
use Flarum\Support\HtmlAction;
|
use Flarum\Support\HtmlAction;
|
||||||
use Flarum\Forum\Events\RenderView;
|
use Flarum\Forum\Events\RenderView;
|
||||||
|
use Illuminate\Database\DatabaseManager;
|
||||||
use Psr\Http\Message\ServerRequestInterface as Request;
|
use Psr\Http\Message\ServerRequestInterface as Request;
|
||||||
use Session;
|
use Symfony\Component\HttpFoundation\Session\SessionInterface;
|
||||||
use DB;
|
|
||||||
|
|
||||||
class IndexAction extends HtmlAction
|
class IndexAction extends HtmlAction
|
||||||
{
|
{
|
||||||
|
@ -15,18 +15,24 @@ class IndexAction extends HtmlAction
|
||||||
|
|
||||||
protected $actor;
|
protected $actor;
|
||||||
|
|
||||||
public function __construct(Client $apiClient, Actor $actor)
|
protected $session;
|
||||||
|
|
||||||
|
protected $database;
|
||||||
|
|
||||||
|
public function __construct(Client $apiClient, Actor $actor, DatabaseManager $database, SessionInterface $session)
|
||||||
{
|
{
|
||||||
$this->apiClient = $apiClient;
|
$this->apiClient = $apiClient;
|
||||||
$this->actor = $actor;
|
$this->actor = $actor;
|
||||||
|
$this->session = $session;
|
||||||
|
$this->database = $database;
|
||||||
}
|
}
|
||||||
|
|
||||||
public function render(Request $request, $params = [])
|
public function render(Request $request, $params = [])
|
||||||
{
|
{
|
||||||
$config = DB::table('config')->whereIn('key', ['base_url', 'api_url', 'forum_title', 'welcome_title', 'welcome_message'])->lists('value', 'key');
|
$config = $this->database->table('config')->whereIn('key', ['base_url', 'api_url', 'forum_title', 'welcome_title', 'welcome_message'])->lists('value', 'key');
|
||||||
$data = [];
|
$data = [];
|
||||||
$session = [];
|
$session = [];
|
||||||
$alert = Session::get('alert');
|
$alert = $this->session->get('alert');
|
||||||
|
|
||||||
if (($user = $this->actor->getUser()) && $user->exists) {
|
if (($user = $this->actor->getUser()) && $user->exists) {
|
||||||
$session = [
|
$session = [
|
||||||
|
|
Loading…
Reference in New Issue
Block a user