mirror of
https://github.com/flarum/core.git
synced 2025-07-21 08:41:17 +02:00
Inject/use new config class where applicable
This commit is contained in:
@@ -11,8 +11,7 @@ namespace Flarum\Http;
|
||||
|
||||
use Dflydev\FigCookies\Modifier\SameSite;
|
||||
use Dflydev\FigCookies\SetCookie;
|
||||
use Flarum\Foundation\Application;
|
||||
use Illuminate\Support\Arr;
|
||||
use Flarum\Foundation\Config;
|
||||
|
||||
class CookieFactory
|
||||
{
|
||||
@@ -52,19 +51,19 @@ class CookieFactory
|
||||
protected $samesite;
|
||||
|
||||
/**
|
||||
* @param Application $app
|
||||
* @param Config $config
|
||||
*/
|
||||
public function __construct(Application $app)
|
||||
public function __construct(Config $config)
|
||||
{
|
||||
// Parse the forum's base URL so that we can determine the optimal cookie settings
|
||||
$url = parse_url(rtrim($app->url(), '/'));
|
||||
// If necessary, we will use the forum's base URL to determine smart defaults for cookie settings
|
||||
$url = $config->url();
|
||||
|
||||
// Get the cookie settings from the config or use the default values
|
||||
$this->prefix = $app->config('cookie.name', 'flarum');
|
||||
$this->path = $app->config('cookie.path', Arr::get($url, 'path') ?: '/');
|
||||
$this->domain = $app->config('cookie.domain');
|
||||
$this->secure = $app->config('cookie.secure', Arr::get($url, 'scheme') === 'https');
|
||||
$this->samesite = $app->config('cookie.samesite');
|
||||
$this->prefix = $config['cookie.name'] ?? 'flarum';
|
||||
$this->path = $config['cookie.path'] ?? $url->getPath() ?: '/';
|
||||
$this->domain = $config['cookie.domain'];
|
||||
$this->secure = $config['cookie.secure'] ?? $url->getScheme() === 'https';
|
||||
$this->samesite = $config['cookie.samesite'];
|
||||
}
|
||||
|
||||
/**
|
||||
|
Reference in New Issue
Block a user