Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Events/UnlinkingFromProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class UnlinkingFromProvider
* @param User $user
* @param LoginProvider $provider
*/
public function __construct(User $user, LoginProvider $provider, User $actor = null)
public function __construct(User $user, LoginProvider $provider, ?User $actor = null)
{
$this->user = $user;
$this->provider = $provider;
Expand Down
2 changes: 1 addition & 1 deletion src/Extend/RegisterProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ public function __construct(string $provider)
$this->provider = $provider;
}

public function extend(Container $container, Extension $extension = null)
public function extend(Container $container, ?Extension $extension = null)
{
$provider = $container->make($this->provider);

Expand Down
2 changes: 1 addition & 1 deletion src/LoginProviderStatus.php
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ class LoginProviderStatus
*/
public $lastLogin;

public static function build(string $name, string $icon, int $priority, User $user, LoginProvider $provider = null, bool $orphaned = false)
public static function build(string $name, string $icon, int $priority, User $user, ?LoginProvider $provider = null, bool $orphaned = false)
{
$status = new self();

Expand Down
17 changes: 15 additions & 2 deletions src/OAuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
namespace FoF\OAuth;

use Flarum\Foundation\AbstractServiceProvider;
use Flarum\Foundation\Config;
use Flarum\Http\RouteCollection;
use Flarum\Http\RouteHandlerFactory;
use Illuminate\Contracts\Cache\Store as Cache;
Expand Down Expand Up @@ -44,8 +45,15 @@ public function boot()
{
/** @var Cache $cache */
$cache = $this->container->make(Cache::class);
/** @var Config $config */
$config = $this->container->make(Config::class);

$this->container->singleton('fof-oauth.providers.forum', function () use ($cache, $config) {
// If we're in debug mode, don't cache the providers, but directly return them.
if ($config->inDebugMode()) {
return $this->mapProviders();
}

$this->container->singleton('fof-oauth.providers.forum', function () use ($cache) {
$cacheKey = 'fof-oauth.providers.forum';

$data = $cache->get($cacheKey);
Expand All @@ -57,7 +65,12 @@ public function boot()
return $data;
});

$this->container->singleton('fof-oauth.providers.admin', function () use ($cache) {
$this->container->singleton('fof-oauth.providers.admin', function () use ($cache, $config) {
// If we're in debug mode, don't cache the providers, but directly return them.
if ($config->inDebugMode()) {
return $this->mapProviders();
}

$cacheKey = 'fof-oauth.providers.admin';

$data = $cache->get($cacheKey);
Expand Down
Loading