Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
bobimicroweber committed Oct 17, 2024
1 parent 1441eaa commit f2f7dc8
Show file tree
Hide file tree
Showing 6 changed files with 82 additions and 32 deletions.
38 changes: 38 additions & 0 deletions web/Modules/Microweber/App/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace Modules\Microweber\App\Providers;

use App\Events\DomainIsChanged;
use Illuminate\Foundation\Support\Providers\EventServiceProvider as ServiceProvider;
use Modules\Microweber\Listeners\DomainIsChangedListener;

class EventServiceProvider extends ServiceProvider
{
/**
* The event to listener mappings for the application.
*
* @var array<class-string, array<int, class-string>>
*/

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;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public function register(): void
});

$this->app->register(RouteServiceProvider::class);
$this->app->register(EventServiceProvider::class);

app()->backupManager->registerConfig(MicroweberBackupConfig::class, $this->moduleNameLower);
app()->virtualHostManager->registerConfig(MicroweberApacheVirtualHostConfig::class, $this->moduleNameLower);
Expand Down
38 changes: 38 additions & 0 deletions web/Modules/Microweber/Listeners/DomainIsChangedListener.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
<?php

namespace Modules\Microweber\Listeners;

use App\Events\DomainIsChanged;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Queue\InteractsWithQueue;
use Modules\Microweber\App\Models\MicroweberInstallation;

class DomainIsChangedListener
{

/**
* Create the event listener.
*/
public function __construct()
{

}

/**
* Handle the event.
*/
public function handle(DomainIsChanged $event): void
{
if (!isset($event->domain->id)) {
return;
}

$findMicroweberInstallation = MicroweberInstallation::where('domain_id', $event->domain->id)->first();
if (!$findMicroweberInstallation) {
return;
}

shell_exec('php '. $findMicroweberInstallation->installation_path . '/artisan cache:clear');

}
}
6 changes: 4 additions & 2 deletions web/app/Events/DomainIsChanged.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}

/**
Expand Down
26 changes: 0 additions & 26 deletions web/app/Listeners/DomainIsChangedListener.php

This file was deleted.

5 changes: 1 addition & 4 deletions web/app/Providers/EventServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ class EventServiceProvider extends ServiceProvider
],
ModelPhyreServerCreated::class => [
ModelPhyreServerCreatedListener::class,
],
DomainIsChanged::class => [
DomainIsChangedListener::class,
],
]
];

/**
Expand Down

0 comments on commit f2f7dc8

Please sign in to comment.