PluginProbe
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler / trunk
FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler vtrunk
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 1.2.0 1.2.1 All 46 releases
fluent-cart / api / StorageDrivers.php

StorageDrivers.php in FluentCart A New Era of eCommerce – Faster, Lighter, and Simpler trunk, at api/StorageDrivers.php

82 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
1 <?php
2
3 namespace FluentCart\Api;
4
5 use FluentCart\App\Services\FileSystem\Drivers\S3\S3FileList;
6 use FluentCart\Framework\Support\Arr;
7
8 class StorageDrivers
9 {
10 /**
11 * @param string $driver name like local, s3 etc
12 * Get storage driver settings
13 * @return array
14 *
15 */
16 public function getSettings($driver)
17 {
18 return apply_filters('fluent_cart/storage/get_global_storage_settings_' . $driver, [], []);
19 }
20
21 /**
22 * @return array
23 *
24 * All storage drivers
25 */
26 public function getAll()
27 {
28 return apply_filters('fluent_cart/storage/get_global_storage_drivers', [], []);
29 }
30
31 /**
32 * @return array
33 *
34 * All active storage drivers
35 */
36 public function getActive($withInstance = false)
37 {
38 $drivers = $this->getAll();
39 $activeDrivers = [];
40
41 foreach ($drivers as $index => $driver) {
42 $settings = $this->getSettings($driver['route']);
43 $instance = $driver['instance'];
44
45
46 if ($instance->isEnabled()) {
47 if(!$withInstance){
48 unset($driver['instance']);
49 }
50 $activeDrivers[$index] = $driver;
51 }
52 }
53
54 return $activeDrivers;
55 }
56
57 /**
58 * @param string $driver name like local, s3 etc
59 * Get storage driver Status
60 * @return array
61 *
62 */
63 public function getStatus($driver)
64 {
65 return apply_filters('fluent_cart/storage/get_global_storage_driver_status_' . $driver, [], []);
66 }
67
68 /**
69 * @param array $data containing connect info and driver name like s3 etc
70 * Get Verify connect info
71 * @return array
72 *
73 */
74 public function verifyConnectInfo(array $data)
75 {
76 $driver = Arr::get($data, 'driver');
77 $settings = Arr::get($data, 'settings');
78
79 return apply_filters('fluent_cart/verify_driver_connect_info_' . sanitize_text_field($driver), $settings, []);
80 }
81 }
82