PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.5.3
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.5.3
1.6.5 1.6.4 1.6.3 1.6.2 1.6.1 1.6.0 1.5.4 1.5.5 1.5.3 1.5.2 1.5.1 1.5.0 1.4.2 1.4.1 1.4.0 1.3.28 1.3.27 1.3.26 1.3.25 1.3.23 1.3.22 1.3.21 1.3.20 1.3.19 trunk All 48 releases
fluent-cart / app / App.php

App.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler 1.5.3, at app/App.php

105 lines 2.8 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCart\App;
4
5 use FluentCart\Api\StoreSettings;
6 use FluentCart\App\Modules\PaymentMethods\Core\GatewayManager;
7 use FluentCart\App\Modules\PaymentMethods\Core\PaymentGatewayInterface;
8 use FluentCart\Framework\Support\Once;
9 use FluentCart\Framework\Foundation\App as AppFacade;
10
11 /**
12 * Class App
13 *
14 * @method static \FluentCart\Framework\Http\Request\Request request() Get the current request instance.
15 * @method static \FluentCart\Framework\Database\DatabaseManager db()
16 * @method static \FluentCart\Framework\Http\Response\Response response()
17 * @method static \FluentCart\Framework\View\View view()
18 * @method static \FluentCart\Framework\Foundation\Config config()
19 */
20
21
22 /**
23 * @method static \FluentCart\Framework\Database\Query\WPDBConnection db()
24 */
25
26 class App extends AppFacade
27 {
28 public static function slug(): string
29 {
30 return static::config()->get('app.slug');
31 }
32
33 public static function route(): \FluentCart\Framework\Http\Route
34 {
35 return static::request()->route();
36 }
37
38 public static function call($action, array $parameters = [])
39 {
40 return static::getInstance()->call(
41 $action,
42 $parameters
43 );
44 }
45
46 public static function storeSettings(): StoreSettings
47 {
48 return Once::call(function () {
49 return new StoreSettings();
50 });
51 }
52
53 /**
54 * Get the payment gateway manager or a specific gateway
55 *
56 * @param string|null $gatewayName Optional gateway name to retrieve directly
57 * @return GatewayManager|PaymentGatewayInterface|null
58 */
59 public static function gateway(?string $gatewayName = null)
60 {
61 $gatewayManager = static::getInstance('gateway');
62
63 // If gateway name is provided, return the specific gateway
64 if ($gatewayName !== null) {
65 return $gatewayManager->get($gatewayName);
66 }
67
68 // Otherwise return the manager instance
69 return $gatewayManager;
70 }
71
72 public static function isProActive(): bool
73 {
74 return defined('FLUENTCART_PRO_PLUGIN_VERSION');
75 }
76
77 public static function doingRestRequest(): bool
78 {
79 if (defined('REST_REQUEST') && REST_REQUEST) {
80 return true;
81 }
82
83 // Fallback: check URL for /wp-json/
84 $rest_prefix = trailingslashit(rest_get_url_prefix());
85 if (isset($_SERVER['REQUEST_URI'])) {
86 $request_uri = sanitize_text_field(wp_unslash($_SERVER['REQUEST_URI']));
87 if (strpos($request_uri, $rest_prefix) !== false) {
88 return true;
89 }
90 }
91
92 return false;
93 }
94
95 public static function isDevMode(): bool
96 {
97 return static::config()->get('env') === 'dev';
98 }
99
100 public static function localization()
101 {
102 return static::getInstance('localization');
103 }
104 }
105