|
25 | 25 | * |
26 | 26 | */ |
27 | 27 |
|
| 28 | +use PaypalPPBTlib\Extensions\Diagnostic\Stubs\Concrete\FileIntegrityStub; |
| 29 | + |
28 | 30 | if (!defined('_PS_VERSION_')) { |
29 | 31 | exit; |
30 | 32 | } |
|
34 | 36 | * |
35 | 37 | * @return bool |
36 | 38 | */ |
37 | | -function upgrade_module_6_4_3($module) |
| 39 | +function upgrade_module_6_4_3(PayPal $module) |
38 | 40 | { |
39 | | - $kit = new \PaypalAddons\services\Kit(); |
40 | | - $baseDir = _PS_ROOT_DIR_ . '/modules/paypal/'; |
41 | | - $dirs = [ |
42 | | - '_dev', |
43 | | - 'classes/APM', |
44 | | - 'views/templates/apm', |
45 | | - 'views/templates/admin/_partials/paypalBanner', |
46 | | - 'views/templates/admin/_partials/form/fields', |
47 | | - ]; |
48 | | - $files = [ |
49 | | - 'controllers/admin/AdminPayPalCustomizeCheckoutController.php', |
50 | | - 'controllers/admin/AdminPayPalHelpController.php', |
51 | | - 'controllers/admin/AdminPayPalInstallmentController.php', |
52 | | - 'controllers/admin/AdminPayPalLogsController.php', |
53 | | - 'controllers/admin/AdminPayPalPUIListenerController.php', |
54 | | - 'controllers/admin/AdminPayPalSetupController.php', |
55 | | - 'controllers/admin/AdminPaypalGetCredentialsController.php', |
56 | | - 'views/templates/admin/customizeCheckout.tpl', |
57 | | - 'views/templates/admin/help.tpl', |
58 | | - 'views/templates/admin/installment.tpl', |
59 | | - 'views/templates/admin/setup.tpl', |
60 | | - 'views/templates/admin/_partials/accountSettingsBlock.tpl', |
61 | | - 'views/templates/admin/_partials/blockPreviewButtonContext.tpl', |
62 | | - 'views/templates/admin/_partials/block_info.tpl', |
63 | | - 'views/templates/admin/_partials/carrierMap.tpl', |
64 | | - 'views/templates/admin/_partials/ecCredentialFields.tpl', |
65 | | - 'views/templates/admin/_partials/headerLogo.tpl', |
66 | | - 'views/templates/admin/_partials/helperOptionInfo.tpl', |
67 | | - 'views/templates/admin/_partials/mbCredentialsForm.tpl', |
68 | | - 'views/templates/admin/_partials/pppCredentialsForm.tpl', |
69 | | - 'views/templates/admin/_partials/roundingSettings.tpl', |
70 | | - 'views/templates/admin/_partials/switchSandboxBlock.tpl', |
71 | | - 'views/templates/admin/_partials/white-list.tpl', |
72 | | - 'views/templates/admin/_partials/form/colorDescriptions.tpl', |
73 | | - 'views/templates/admin/_partials/form/customizeStyleSection.tpl', |
74 | | - 'views/templates/admin/_partials/form/sectionTitle.tpl', |
75 | | - ]; |
| 41 | + $baseDir = _PS_MODULE_DIR_ . 'paypal/'; |
| 42 | + $diagnosticConf = include _PS_MODULE_DIR_ . 'paypal/diagnostic.php'; |
| 43 | + |
| 44 | + if (empty($diagnosticConf[0]['stubs'][FileIntegrityStub::class])) { |
| 45 | + return true; |
| 46 | + } |
76 | 47 |
|
77 | | - foreach ($dirs as $dir) { |
78 | | - $kit->rrmdir($baseDir . $dir); |
| 48 | + $stub = new FileIntegrityStub($diagnosticConf[0]['stubs'][FileIntegrityStub::class]); |
| 49 | + $stub->setModule($module); |
| 50 | + $response = $stub->getHandler()->handle(); |
| 51 | + |
| 52 | + if (empty($response['created'])) { |
| 53 | + return true; |
79 | 54 | } |
| 55 | + |
| 56 | + $files = array_filter( |
| 57 | + $response['created'], |
| 58 | + function ($file) { |
| 59 | + return !preg_match('/^config_[a-z]+\.xml$/', $file) && $file !== 'config.xml'; |
| 60 | + }); |
| 61 | + |
80 | 62 | foreach ($files as $file) { |
81 | | - $kit->unlink($baseDir . $file); |
| 63 | + try { |
| 64 | + unlink($baseDir . $file); |
| 65 | + } catch (Exception $e) { |
| 66 | + } catch (Throwable $e) { |
| 67 | + } |
82 | 68 | } |
83 | 69 |
|
84 | 70 | return true; |
|
0 commit comments