vito/app/SiteTypes/AbstractSiteType.php
Saeed Vaziry 428140b931
refactoring (#116)
- refactoring architecture
- fix incomplete ssh logs
- code editor for scripts in the app
- remove Jobs and SSHCommands
2024-03-14 20:03:43 +01:00

39 lines
932 B
PHP
Executable File

<?php
namespace App\SiteTypes;
use App\Exceptions\SourceControlIsNotConnected;
use App\Models\Site;
abstract class AbstractSiteType implements SiteType
{
protected Site $site;
public function __construct(Site $site)
{
$this->site = $site;
}
protected function progress(int $percentage): void
{
$this->site->progress = $percentage;
$this->site->save();
}
/**
* @throws SourceControlIsNotConnected
*/
protected function deployKey(): void
{
$os = $this->site->server->os();
$os->generateSSHKey($this->site->getSshKeyName());
$this->site->ssh_key = $os->readSSHKey($this->site->getSshKeyName());
$this->site->save();
$this->site->sourceControl()->provider()->deployKey(
$this->site->domain.'-key-'.$this->site->id,
$this->site->repository,
$this->site->ssh_key
);
}
}