mirror of
https://github.com/flarum/framework.git
synced 2025-01-20 02:32:45 +08:00
Inject SettingsRepository where possible
This commit is contained in:
parent
74a27f8ba2
commit
c5dd0ad372
|
@ -1,5 +1,6 @@
|
||||||
<?php namespace Flarum\Core\Users\Commands;
|
<?php namespace Flarum\Core\Users\Commands;
|
||||||
|
|
||||||
|
use Flarum\Core\Settings\SettingsRepository;
|
||||||
use Flarum\Core\Users\PasswordToken;
|
use Flarum\Core\Users\PasswordToken;
|
||||||
use Flarum\Core\Users\UserRepository;
|
use Flarum\Core\Users\UserRepository;
|
||||||
use Illuminate\Contracts\Mail\Mailer;
|
use Illuminate\Contracts\Mail\Mailer;
|
||||||
|
@ -15,19 +16,31 @@ class RequestPasswordResetHandler
|
||||||
*/
|
*/
|
||||||
protected $users;
|
protected $users;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var SettingsRepository
|
||||||
|
*/
|
||||||
|
protected $settings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Mailer
|
* @var Mailer
|
||||||
*/
|
*/
|
||||||
protected $mailer;
|
protected $mailer;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var UrlGeneratorInterface
|
||||||
|
*/
|
||||||
|
protected $url;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param UserRepository $users
|
* @param UserRepository $users
|
||||||
|
* @param SettingsRepository $settings
|
||||||
* @param Mailer $mailer
|
* @param Mailer $mailer
|
||||||
* @param UrlGeneratorInterface $url
|
* @param UrlGeneratorInterface $url
|
||||||
*/
|
*/
|
||||||
public function __construct(UserRepository $users, Mailer $mailer, UrlGeneratorInterface $url)
|
public function __construct(UserRepository $users, SettingsRepository $settings, Mailer $mailer, UrlGeneratorInterface $url)
|
||||||
{
|
{
|
||||||
$this->users = $users;
|
$this->users = $users;
|
||||||
|
$this->settings = $settings;
|
||||||
$this->mailer = $mailer;
|
$this->mailer = $mailer;
|
||||||
$this->url = $url;
|
$this->url = $url;
|
||||||
}
|
}
|
||||||
|
@ -53,8 +66,8 @@ class RequestPasswordResetHandler
|
||||||
// password route be part of core??
|
// password route be part of core??
|
||||||
$data = [
|
$data = [
|
||||||
'username' => $user->username,
|
'username' => $user->username,
|
||||||
'url' => Core::config('base_url').'/reset/'.$token->id,
|
'url' => $this->settings->get('base_url').'/reset/'.$token->id,
|
||||||
'forumTitle' => Core::config('forum_title')
|
'forumTitle' => $this->settings->get('forum_title'),
|
||||||
];
|
];
|
||||||
|
|
||||||
$this->mailer->send(['text' => 'flarum::emails.resetPassword'], $data, function (Message $message) use ($user) {
|
$this->mailer->send(['text' => 'flarum::emails.resetPassword'], $data, function (Message $message) use ($user) {
|
||||||
|
|
|
@ -1,5 +1,6 @@
|
||||||
<?php namespace Flarum\Core\Users\Listeners;
|
<?php namespace Flarum\Core\Users\Listeners;
|
||||||
|
|
||||||
|
use Flarum\Core\Settings\SettingsRepository;
|
||||||
use Flarum\Core\Users\Events\UserWasRegistered;
|
use Flarum\Core\Users\Events\UserWasRegistered;
|
||||||
use Flarum\Core\Users\Events\UserEmailChangeWasRequested;
|
use Flarum\Core\Users\Events\UserEmailChangeWasRequested;
|
||||||
use Flarum\Core;
|
use Flarum\Core;
|
||||||
|
@ -11,16 +12,23 @@ use Illuminate\Mail\Message;
|
||||||
|
|
||||||
class EmailConfirmationMailer
|
class EmailConfirmationMailer
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @var SettingsRepository
|
||||||
|
*/
|
||||||
|
protected $settings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var Mailer
|
* @var Mailer
|
||||||
*/
|
*/
|
||||||
protected $mailer;
|
protected $mailer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
* @param SettingsRepository $settings
|
||||||
* @param Mailer $mailer
|
* @param Mailer $mailer
|
||||||
*/
|
*/
|
||||||
public function __construct(Mailer $mailer)
|
public function __construct(SettingsRepository $settings, Mailer $mailer)
|
||||||
{
|
{
|
||||||
|
$this->settings = $settings;
|
||||||
$this->mailer = $mailer;
|
$this->mailer = $mailer;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -90,8 +98,8 @@ class EmailConfirmationMailer
|
||||||
// email route be part of core??
|
// email route be part of core??
|
||||||
return [
|
return [
|
||||||
'username' => $user->username,
|
'username' => $user->username,
|
||||||
'url' => Core::config('base_url').'/confirm/'.$token->id,
|
'url' => $this->settings->get('base_url').'/confirm/'.$token->id,
|
||||||
'forumTitle' => Core::config('forum_title')
|
'forumTitle' => $this->settings->get('forum_title')
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ use Flarum\Assets\AssetManager;
|
||||||
use Flarum\Assets\JsCompiler;
|
use Flarum\Assets\JsCompiler;
|
||||||
use Flarum\Assets\LessCompiler;
|
use Flarum\Assets\LessCompiler;
|
||||||
use Flarum\Core;
|
use Flarum\Core;
|
||||||
|
use Flarum\Core\Settings\SettingsRepository;
|
||||||
use Flarum\Core\Users\User;
|
use Flarum\Core\Users\User;
|
||||||
use Flarum\Locale\JsCompiler as LocaleJsCompiler;
|
use Flarum\Locale\JsCompiler as LocaleJsCompiler;
|
||||||
use Flarum\Locale\LocaleManager;
|
use Flarum\Locale\LocaleManager;
|
||||||
|
@ -61,14 +62,20 @@ abstract class ClientAction extends HtmlAction
|
||||||
*/
|
*/
|
||||||
protected $locales;
|
protected $locales;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @var SettingsRepository
|
||||||
|
*/
|
||||||
|
protected $settings;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param Client $apiClient
|
* @param Client $apiClient
|
||||||
* @param LocaleManager $locales
|
* @param LocaleManager $locales
|
||||||
*/
|
*/
|
||||||
public function __construct(Client $apiClient, LocaleManager $locales)
|
public function __construct(Client $apiClient, LocaleManager $locales, SettingsRepository $settings)
|
||||||
{
|
{
|
||||||
$this->apiClient = $apiClient;
|
$this->apiClient = $apiClient;
|
||||||
$this->locales = $locales;
|
$this->locales = $locales;
|
||||||
|
$this->settings = $settings;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -156,7 +163,7 @@ abstract class ClientAction extends HtmlAction
|
||||||
$assets->addLess("@$name: $value;");
|
$assets->addLess("@$name: $value;");
|
||||||
}
|
}
|
||||||
|
|
||||||
$assets->addLess(Core::config('custom_less'));
|
$assets->addLess($this->settings->get('custom_less'));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -168,10 +175,10 @@ abstract class ClientAction extends HtmlAction
|
||||||
protected function getLessVariables()
|
protected function getLessVariables()
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
'fl-primary-color' => Core::config('theme_primary_color', '#000'),
|
'fl-primary-color' => $this->settings->get('theme_primary_color', '#000'),
|
||||||
'fl-secondary-color' => Core::config('theme_secondary_color', '#000'),
|
'fl-secondary-color' => $this->settings->get('theme_secondary_color', '#000'),
|
||||||
'fl-dark-mode' => Core::config('theme_dark_mode') ? 'true' : 'false',
|
'fl-dark-mode' => $this->settings->get('theme_dark_mode') ? 'true' : 'false',
|
||||||
'fl-colored-header' => Core::config('theme_colored_header') ? 'true' : 'false'
|
'fl-colored-header' => $this->settings->get('theme_colored_header') ? 'true' : 'false'
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user