Replace magic facades

This commit is contained in:
James Cole
2025-05-24 17:15:46 +02:00
parent e333dedeec
commit b830bd2732
14 changed files with 38 additions and 23 deletions

View File

@@ -28,6 +28,7 @@ use FireflyIII\Models\Configuration;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Contracts\Encryption\EncryptException;
use Illuminate\Database\QueryException;
use Illuminate\Support\Facades\Cache;
use Illuminate\Support\Facades\Log;
/**
@@ -38,8 +39,8 @@ class FireflyConfig
public function delete(string $name): void
{
$fullName = 'ff-config-'.$name;
if (\Cache::has($fullName)) {
\Cache::forget($fullName);
if (Cache::has($fullName)) {
Cache::forget($fullName);
}
Configuration::where('name', $name)->forceDelete();
}
@@ -80,8 +81,8 @@ class FireflyConfig
public function get(string $name, mixed $default = null): ?Configuration
{
$fullName = 'ff-config-'.$name;
if (\Cache::has($fullName)) {
return \Cache::get($fullName);
if (Cache::has($fullName)) {
return Cache::get($fullName);
}
try {
@@ -92,7 +93,7 @@ class FireflyConfig
}
if (null !== $config) {
\Cache::forever($fullName, $config);
Cache::forever($fullName, $config);
return $config;
}
@@ -122,13 +123,13 @@ class FireflyConfig
$item->name = $name;
$item->data = $value;
$item->save();
\Cache::forget('ff-config-'.$name);
Cache::forget('ff3-config-'.$name);
return $item;
}
$config->data = $value;
$config->save();
\Cache::forget('ff-config-'.$name);
Cache::forget('ff3-config-'.$name);
return $config;
}

View File

@@ -26,6 +26,7 @@ namespace FireflyIII\Support\System;
use FireflyIII\Exceptions\FireflyException;
use Illuminate\Contracts\Encryption\DecryptException;
use Illuminate\Support\Facades\Artisan;
use Illuminate\Support\Facades\Crypt;
use Laravel\Passport\Console\KeysCommand;
use Psr\Container\ContainerExceptionInterface;
@@ -88,8 +89,8 @@ class OAuthKeys
public static function generateKeys(): void
{
\Artisan::registerCommand(new KeysCommand());
\Artisan::call('firefly-iii:laravel-passport-keys');
Artisan::registerCommand(new KeysCommand());
Artisan::call('firefly-iii:laravel-passport-keys');
}
public static function storeKeysInDB(): void

View File

@@ -247,7 +247,7 @@ class General extends AbstractExtension
static function (): string {
$args = func_get_args();
$route = $args[0]; // name of the route.
$name = \Route::getCurrentRoute()->getName() ?? '';
$name = Route::getCurrentRoute()->getName() ?? '';
if (str_contains($name, $route)) {
return 'active';
}
@@ -271,7 +271,7 @@ class General extends AbstractExtension
if ($objectType === $activeObjectType
&& false !== stripos(
(string) \Route::getCurrentRoute()->getName(),
(string) Route::getCurrentRoute()->getName(),
(string) $route
)) {
return 'active';
@@ -294,7 +294,7 @@ class General extends AbstractExtension
static function (): string {
$args = func_get_args();
$route = $args[0]; // name of the route.
$name = \Route::getCurrentRoute()->getName() ?? '';
$name = Route::getCurrentRoute()->getName() ?? '';
if (str_contains($name, $route)) {
return 'menu-open';
}