vito/app/Jobs/Installation/UninstallPHPMyAdmin.php
Saeed Vaziry b2083fc6b2
Migrate to HTMX (#114)
Dropped Livewire
Added HTMX
Added Blade code lint
Drop Mysql and Redis
Migrate to SQLite
2024-03-06 17:02:59 +01:00

67 lines
1.4 KiB
PHP

<?php
namespace App\Jobs\Installation;
use App\Jobs\Job;
use App\Models\FirewallRule;
use App\Models\Service;
use App\SSHCommands\PHPMyAdmin\DeleteNginxPHPMyAdminVHostCommand;
use Exception;
use Throwable;
/**
* @deprecated
*/
class UninstallPHPMyAdmin extends Job
{
protected Service $service;
public function __construct(Service $service)
{
$this->service = $service;
}
/**
* @throws Exception
* @throws Throwable
*/
public function handle(): void
{
$this->removeFirewallRule();
$this->deleteVHost();
$this->restartPHP();
}
/**
* @throws Exception
*/
private function removeFirewallRule(): void
{
/** @var ?FirewallRule $rule */
$rule = FirewallRule::query()
->where('server_id', $this->service->server_id)
->where('port', $this->service->type_data['port'])
->first();
$rule?->removeFromServer();
}
/**
* @throws Throwable
*/
private function deleteVHost(): void
{
$this->service->server->ssh()->exec(
new DeleteNginxPHPMyAdminVHostCommand('/home/vito/phpmyadmin'),
'delete-phpmyadmin-vhost'
);
}
private function restartPHP(): void
{
$this->service->server->service(
'php',
$this->service->type_data['php']
)?->restart();
}
}