From f2f7dc815e38b2f8c23b8b6f514ab5f3a0ce45f3 Mon Sep 17 00:00:00 2001 From: Bozhidar Date: Thu, 17 Oct 2024 11:48:23 +0300 Subject: [PATCH] update --- .../App/Providers/EventServiceProvider.php | 38 +++++++++++++++++++ .../Providers/MicroweberServiceProvider.php | 1 + .../Listeners/DomainIsChangedListener.php | 38 +++++++++++++++++++ web/app/Events/DomainIsChanged.php | 6 ++- web/app/Listeners/DomainIsChangedListener.php | 26 ------------- web/app/Providers/EventServiceProvider.php | 5 +-- 6 files changed, 82 insertions(+), 32 deletions(-) create mode 100644 web/Modules/Microweber/App/Providers/EventServiceProvider.php create mode 100644 web/Modules/Microweber/Listeners/DomainIsChangedListener.php delete mode 100644 web/app/Listeners/DomainIsChangedListener.php diff --git a/web/Modules/Microweber/App/Providers/EventServiceProvider.php b/web/Modules/Microweber/App/Providers/EventServiceProvider.php new file mode 100644 index 0000000..2a091eb --- /dev/null +++ b/web/Modules/Microweber/App/Providers/EventServiceProvider.php @@ -0,0 +1,38 @@ +> + */ + + protected $listen = [ + DomainIsChanged::class => [ + DomainIsChangedListener::class, + ], + ]; + + /** + * Register any events for your application. + */ + public function boot(): void + { + // + } + + /** + * Determine if events and listeners should be automatically discovered. + */ + public function shouldDiscoverEvents(): bool + { + return false; + } +} diff --git a/web/Modules/Microweber/App/Providers/MicroweberServiceProvider.php b/web/Modules/Microweber/App/Providers/MicroweberServiceProvider.php index 13a1da0..f7cbfbb 100644 --- a/web/Modules/Microweber/App/Providers/MicroweberServiceProvider.php +++ b/web/Modules/Microweber/App/Providers/MicroweberServiceProvider.php @@ -47,6 +47,7 @@ class MicroweberServiceProvider extends ServiceProvider }); $this->app->register(RouteServiceProvider::class); + $this->app->register(EventServiceProvider::class); app()->backupManager->registerConfig(MicroweberBackupConfig::class, $this->moduleNameLower); app()->virtualHostManager->registerConfig(MicroweberApacheVirtualHostConfig::class, $this->moduleNameLower); diff --git a/web/Modules/Microweber/Listeners/DomainIsChangedListener.php b/web/Modules/Microweber/Listeners/DomainIsChangedListener.php new file mode 100644 index 0000000..27bcfdb --- /dev/null +++ b/web/Modules/Microweber/Listeners/DomainIsChangedListener.php @@ -0,0 +1,38 @@ +domain->id)) { + return; + } + + $findMicroweberInstallation = MicroweberInstallation::where('domain_id', $event->domain->id)->first(); + if (!$findMicroweberInstallation) { + return; + } + + shell_exec('php '. $findMicroweberInstallation->installation_path . '/artisan cache:clear'); + + } +} diff --git a/web/app/Events/DomainIsChanged.php b/web/app/Events/DomainIsChanged.php index 9dcb915..dba895e 100644 --- a/web/app/Events/DomainIsChanged.php +++ b/web/app/Events/DomainIsChanged.php @@ -14,12 +14,14 @@ class DomainIsChanged { use Dispatchable, InteractsWithSockets, SerializesModels; + public $domain; + /** * Create a new event instance. */ - public function __construct() + public function __construct($domain) { - // + $this->domain = $domain; } /** diff --git a/web/app/Listeners/DomainIsChangedListener.php b/web/app/Listeners/DomainIsChangedListener.php deleted file mode 100644 index cd6ce5d..0000000 --- a/web/app/Listeners/DomainIsChangedListener.php +++ /dev/null @@ -1,26 +0,0 @@ - [ ModelPhyreServerCreatedListener::class, - ], - DomainIsChanged::class => [ - DomainIsChangedListener::class, - ], + ] ]; /**