vito/app/SiteTypes/AbstractSiteType.php
Saeed Vaziry e997d0deea
WIP notifications and other refactors (#88)
* WIP notifications and other refactors
- refactor notification channels
- send notifications on events related to the servers and sites
- delete server log files on server deletion
- add telegram notification channel
- add new icons
- cache configs and icons on installation and updates
- new navbar for dark mode and settings

* discord channel

* build assets

* pint
2024-01-07 09:54:08 +01:00

39 lines
854 B
PHP
Executable File

<?php
namespace App\SiteTypes;
use App\Contracts\SiteType;
use App\Events\Broadcast;
use App\Jobs\Site\DeleteSite;
use App\Models\Site;
use Closure;
abstract class AbstractSiteType implements SiteType
{
protected Site $site;
public function __construct(Site $site)
{
$this->site = $site;
}
public function delete(): void
{
dispatch(new DeleteSite($this->site))->onConnection('ssh');
}
protected function progress(int $percentage): Closure
{
return function () use ($percentage) {
$this->site->progress = $percentage;
$this->site->save();
event(
new Broadcast('site-installation-progress', [
'site' => $this->site,
'percentage' => $percentage,
])
);
};
}
}