This commit is contained in:
Bozhidar 2024-05-16 11:53:58 +03:00
parent 58856b8ae4
commit 909ed5ba70
5 changed files with 81 additions and 0 deletions

View file

@ -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);
}

View file

@ -0,0 +1,17 @@
<?php
namespace Modules\Microweber;
use App\Backup\Abstract\BackupConfigBase;
class MicroweberBackupConfig extends BackupConfigBase
{
public array $excludePaths = [
'/storage/framework/cache',
'/storage/framework/views',
'/userfiles/cache',
'/userfiles/media/thumbnails',
'/storage/framework/sessions',
];
}

View file

@ -0,0 +1,17 @@
<?php
namespace App\Backup\Abstract;
abstract class BackupConfigBase
{
public array $excludePaths = [
];
public function getConfig()
{
$configValues = [];
$configValues['excludePaths'] = $this->excludePaths;
return $configValues;
}
}

View file

@ -0,0 +1,44 @@
<?php
namespace App\Backup;
class BackupManager
{
public $registerConfigs = [];
public function registerConfig($config, $module = null)
{
$this->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;
}
}

View file

@ -5,6 +5,7 @@ namespace App;
use Illuminate\Foundation\Application;
/**
* @property \App\Backup\BackupManager $backupManager
* @property \App\VirtualHosts\ApacheVirtualHostManager $virtualHostManager
*/
class PhyreLaravelApplication extends Application