From 909ed5ba70a368b3ac1337583906f7e4c0c5fe65 Mon Sep 17 00:00:00 2001 From: Bozhidar Date: Thu, 16 May 2024 11:53:58 +0300 Subject: [PATCH] update --- .../Providers/MicroweberServiceProvider.php | 2 + .../Microweber/MicroweberBackupConfig.php | 17 +++++++ web/app/Backup/Abstract/BackupConfigBase.php | 17 +++++++ web/app/Backup/BackupManager.php | 44 +++++++++++++++++++ web/app/PhyreLaravelApplication.php | 1 + 5 files changed, 81 insertions(+) create mode 100644 web/Modules/Microweber/MicroweberBackupConfig.php create mode 100644 web/app/Backup/Abstract/BackupConfigBase.php create mode 100644 web/app/Backup/BackupManager.php diff --git a/web/Modules/Microweber/App/Providers/MicroweberServiceProvider.php b/web/Modules/Microweber/App/Providers/MicroweberServiceProvider.php index 1c485c0..3e6f84b 100644 --- a/web/Modules/Microweber/App/Providers/MicroweberServiceProvider.php +++ b/web/Modules/Microweber/App/Providers/MicroweberServiceProvider.php @@ -10,6 +10,7 @@ use Illuminate\Support\ServiceProvider; use Modules\Microweber\App\Console\Commands\RunDomainRepair; use Modules\Microweber\Listeners\DomainIsCreatedListener; use Modules\Microweber\MicroweberApacheVirtualHostConfig; +use Modules\Microweber\MicroweberBackupConfig; class MicroweberServiceProvider extends ServiceProvider { @@ -47,6 +48,7 @@ class MicroweberServiceProvider extends ServiceProvider $this->app->register(RouteServiceProvider::class); + app()->backupManager->registerConfig(MicroweberBackupConfig::class, $this->moduleNameLower); app()->virtualHostManager->registerConfig(MicroweberApacheVirtualHostConfig::class, $this->moduleNameLower); } diff --git a/web/Modules/Microweber/MicroweberBackupConfig.php b/web/Modules/Microweber/MicroweberBackupConfig.php new file mode 100644 index 0000000..b2327ae --- /dev/null +++ b/web/Modules/Microweber/MicroweberBackupConfig.php @@ -0,0 +1,17 @@ +excludePaths; + + return $configValues; + } +} diff --git a/web/app/Backup/BackupManager.php b/web/app/Backup/BackupManager.php new file mode 100644 index 0000000..bfb158d --- /dev/null +++ b/web/app/Backup/BackupManager.php @@ -0,0 +1,44 @@ +registerConfigs[$module][] = $config; + } + + public function getConfigs($forModules = []) + { + $allConfigs = []; + foreach ($this->registerConfigs as $module => $configs) { + if (empty($forModules)) { + continue; + } + if (! in_array($module, $forModules)) { + continue; + } + foreach ($configs as $config) { + try { + $registerConfigInstance = app()->make($config); + $getConfig = $registerConfigInstance->getConfig(); + if (! empty($getConfig)) { + foreach ($getConfig as $key => $value) { + if (! isset($allConfigs[$key])) { + $allConfigs[$key] = []; + } + $allConfigs[$key] = array_merge($allConfigs[$key], $value); + } + } + } catch (\Exception $e) { + // can't create instance + } + } + } + + return $allConfigs; + } +} diff --git a/web/app/PhyreLaravelApplication.php b/web/app/PhyreLaravelApplication.php index 58ccb3e..30c7b89 100644 --- a/web/app/PhyreLaravelApplication.php +++ b/web/app/PhyreLaravelApplication.php @@ -5,6 +5,7 @@ namespace App; use Illuminate\Foundation\Application; /** + * @property \App\Backup\BackupManager $backupManager * @property \App\VirtualHosts\ApacheVirtualHostManager $virtualHostManager */ class PhyreLaravelApplication extends Application