| @@ -2,9 +2,10 @@ | ||
| 2 | 2 | |
| 3 | 3 | namespace FluentCart\App; |
| 4 | 4 | |
| 5 | 5 | use FluentCart\Api\StoreSettings; |
| 6 | -use FluentCart\Framework\Support\Once; | |
| 6 | +use FluentCart\App\Modules\PaymentMethods\Core\GatewayManager; | |
| 7 | +use FluentCart\App\Modules\PaymentMethods\Core\PaymentGatewayInterface; | |
| 7 | 8 | use FluentCart\Framework\Foundation\App as AppFacade; |
| 8 | 9 | |
| 9 | 10 | /** |
| 10 | 11 | * Class App |
| @@ -9,9 +10,9 @@ | ||
| 9 | 10 | /** |
| 10 | 11 | * Class App |
| 11 | 12 | * |
| 12 | 13 | * @method static \FluentCart\Framework\Http\Request\Request request() Get the current request instance. |
| 13 | - * @method static \FluentCart\Framework\Database\DBManager db() | |
| 14 | + * @method static \FluentCart\Framework\Database\DatabaseManager db() | |
| 14 | 15 | * @method static \FluentCart\Framework\Http\Response\Response response() |
| 15 | 16 | * @method static \FluentCart\Framework\View\View view() |
| 16 | 17 | * @method static \FluentCart\Framework\Foundation\Config config() |
| 17 | 18 | */ |
| @@ -22,14 +23,14 @@ | ||
| 22 | 23 | */ |
| 23 | 24 | |
| 24 | 25 | class App extends AppFacade |
| 25 | 26 | { |
| 26 | - public static function slug() | |
| 27 | + public static function slug(): string | |
| 27 | 28 | { |
| 28 | 29 | return static::config()->get('app.slug'); |
| 29 | 30 | } |
| 30 | 31 | |
| 31 | - public static function route() | |
| 32 | + public static function route(): \FluentCart\Framework\Http\Route | |
| 32 | 33 | { |
| 33 | 34 | return static::request()->route(); |
| 34 | 35 | } |
| 35 | 36 | |
| @@ -40,13 +41,19 @@ | ||
| 40 | 41 | $parameters |
| 41 | 42 | ); |
| 42 | 43 | } |
| 43 | 44 | |
| 44 | - public static function storeSettings() | |
| 45 | + public static function storeSettings(): StoreSettings | |
| 45 | 46 | { |
| 46 | - return Once::call(function () { | |
| 47 | - return new StoreSettings(); | |
| 48 | - }); | |
| 47 | + $cached = wp_cache_get(StoreSettings::CACHE_KEY, StoreSettings::CACHE_GROUP); | |
| 48 | + if ($cached instanceof StoreSettings) { | |
| 49 | + return $cached; | |
| 50 | + } | |
| 51 | + | |
| 52 | + $storeSettings = new StoreSettings(); | |
| 53 | + wp_cache_set(StoreSettings::CACHE_KEY, $storeSettings, StoreSettings::CACHE_GROUP); | |
| 54 | + | |
| 55 | + return $storeSettings; | |
| 49 | 56 | } |
| 50 | 57 | |
| 51 | 58 | /** |
| 52 | 59 | * Get the payment gateway manager or a specific gateway |
| @@ -51,9 +58,9 @@ | ||
| 51 | 58 | /** |
| 52 | 59 | * Get the payment gateway manager or a specific gateway |
| 53 | 60 | * |
| 54 | 61 | * @param string|null $gatewayName Optional gateway name to retrieve directly |
| 55 | - * @return \FluentCart\App\Modules\PaymentMethods\Core\GatewayManager|\FluentCart\App\Modules\PaymentMethods\Core\PaymentGatewayInterface|null | |
| 62 | + * @return GatewayManager|PaymentGatewayInterface|null | |
| 56 | 63 | */ |
| 57 | 64 | public static function gateway(?string $gatewayName = null) |
| 58 | 65 | { |
| 59 | 66 | $gatewayManager = static::getInstance('gateway'); |
| @@ -66,14 +73,14 @@ | ||
| 66 | 73 | // Otherwise return the manager instance |
| 67 | 74 | return $gatewayManager; |
| 68 | 75 | } |
| 69 | 76 | |
| 70 | - public static function isProActive() | |
| 77 | + public static function isProActive(): bool | |
| 71 | 78 | { |
| 72 | 79 | return defined('FLUENTCART_PRO_PLUGIN_VERSION'); |
| 73 | 80 | } |
| 74 | 81 | |
| 75 | - public static function doingRestRequest() | |
| 82 | + public static function doingRestRequest(): bool | |
| 76 | 83 | { |
| 77 | 84 | if (defined('REST_REQUEST') && REST_REQUEST) { |
| 78 | 85 | return true; |
| 79 | 86 | } |
| @@ -89,9 +96,9 @@ | ||
| 89 | 96 | |
| 90 | 97 | return false; |
| 91 | 98 | } |
| 92 | 99 | |
| 93 | - public static function isDevMode() | |
| 100 | + public static function isDevMode(): bool | |
| 94 | 101 | { |
| 95 | 102 | return static::config()->get('env') === 'dev'; |
| 96 | 103 | } |
| 97 | 104 | |