PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / 1.6.6
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler v1.6.6
1.6.6 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 All 49 releases
← All changes | app/Modules/StorageDrivers/BaseStorageDriver.php +66 -16 1.3.20 → 1.6.6 View file →
@@ -25,8 +25,13 @@
25 25 public static $routes = [];
26 26
27 27 abstract public function getLogo();
28 28
29 + public function getDarkLogo()
30 + {
31 + return null;
32 + }
33 +
29 34 abstract public function getDescription();
30 35
31 36 abstract public function getSettings();
32 37
@@ -90,8 +95,9 @@
90 95 "title" => $this->title,
91 96 "route" => $this->slug,
92 97 "description" => $this->getDescription(),
93 98 "logo" => $this->getLogo(),
99 + "dark_logo" => $this->getDarkLogo(),
94 100 "status" => $this->isEnabled(),
95 101 "brand_color" => $this->brandColor,
96 102 "has_bucket" => $this->hasBucket(),
97 103 "instance" => $this
@@ -97,22 +103,10 @@
97 103 "instance" => $this
98 104 ];
99 105
100 106 if ($this->hasBucket()) {
101 - $bucketList = Arr::get($this->getSettings(), 'buckets', []);
102 -
103 - $buckets = [];
104 -
105 - if (is_array($bucketList)) {
106 - foreach ($bucketList as $bucket) {
107 - $buckets[] = array(
108 - "label" => $bucket,
109 - "value" => $bucket,
110 - );
111 - }
112 - }
113 -
114 - $data['buckets'] = $buckets;
107 + $data['need_reconfigure'] = $this->needsReconfigure();
108 + $data['buckets'] = [];
115 109 }
116 110 static::$drivers[$this->slug] = $data;
117 111 return static::$drivers;
118 112 }
@@ -121,8 +115,26 @@
121 115 {
122 116 return false;
123 117 }
124 118
119 + /**
120 + * The bucket this driver is configured to use, resolved from server-side
121 + * settings only. Bucket-backed drivers override this; it is the single
122 + * source of truth for signing downloads, so a request-supplied bucket must
123 + * never reach it.
124 + *
125 + * @return string '' when the driver has no bucket or none is configured yet
126 + */
127 + public function getEffectiveBucket(): string
128 + {
129 + return '';
130 + }
131 +
132 + public function needsReconfigure(): bool
133 + {
134 + return false;
135 + }
136 +
125 137 public function getActiveStatus($data, $args)
126 138 {
127 139 $settings = $this->getSettings();
128 140 return Arr::get($settings, 'is_active') === 'yes' ? true : false;
@@ -142,8 +154,15 @@
142 154 {
143 155 return $this->updateSettings($data);
144 156 }
145 157
158 + public function resetSettings()
159 + {
160 + fluent_cart_update_option($this->driverHandler, []);
161 +
162 + return $this->getSettings();
163 + }
164 +
146 165 public function updateSettings($data)
147 166 {
148 167 $oldSettings = $this->getSettings();
149 168
@@ -164,14 +183,46 @@
164 183 $filtered = Collection::make($this->fields())->filter(function ($item) {
165 184 return Arr::get($item, 'visible', 'yes') === 'yes';
166 185 })->toArray();
167 186
168 - return [
187 + $response = [
169 188 'fields' => $filtered,
170 189 'settings' => Arr::except($this->getSettings(), $this->hiddenSettingKeys())
171 190 ];
191 +
192 + if ($this->hasSettingsTemplate()) {
193 + $response['template'] = $this->getSettingsTemplate();
194 + $response['template_payload'] = $this->getSettingsTemplatePayload($response);
195 + }
196 +
197 + $response = apply_filters('fluent_cart/storage/settings_response', $response, $this);
198 +
199 + return apply_filters('fluent_cart/storage/settings_response_' . $this->slug, $response, $this);
172 200 }
173 201
202 + public function hasSettingsTemplate(): bool
203 + {
204 + return (bool) $this->getSettingsTemplate();
205 + }
206 +
207 + public function getSettingsTemplate(): ?string
208 + {
209 + return null;
210 + }
211 +
212 + public function getSettingsTemplatePayload(array $response = []): array
213 + {
214 + return [
215 + 'driver' => $this->slug,
216 + 'driver_label' => $this->title,
217 + 'description' => $this->getDescription(),
218 + 'logo' => $this->getLogo(),
219 + 'dark_logo' => $this->getDarkLogo(),
220 + 'settings' => Arr::get($response, 'settings', []),
221 + 'fields' => Arr::get($response, 'fields', [])
222 + ];
223 + }
224 +
174 225 public function sanitize($data, $fields)
175 226 {
176 227 foreach ($fields as $key => $value) {
177 228 if (isset($data[$key])) {
@@ -195,5 +246,4 @@
195 246 }
196 247
197 248 abstract public function getDriverClass(): string;
198 249 }
199 -