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, - ], + ] ]; /**