mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-08 01:12:34 +00:00
* wip * wip * cleanup * notification channels * phpstan * services * remove server types * refactoring * refactoring
62 lines
1.2 KiB
PHP
62 lines
1.2 KiB
PHP
<?php
|
|
|
|
namespace App\Plugins;
|
|
|
|
use App\DTOs\DynamicForm;
|
|
|
|
class RegisterSourceControl
|
|
{
|
|
public function __construct(
|
|
private string $name,
|
|
private string $label = '',
|
|
private string $handler = '',
|
|
private ?DynamicForm $form = null,
|
|
) {}
|
|
|
|
public static function make(string $name): self
|
|
{
|
|
return new self($name);
|
|
}
|
|
|
|
public function name(string $name): self
|
|
{
|
|
$this->name = $name;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function label(string $label): self
|
|
{
|
|
$this->label = $label;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function handler(string $handler): self
|
|
{
|
|
$this->handler = $handler;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function form(DynamicForm $form): self
|
|
{
|
|
$this->form = $form;
|
|
|
|
return $this;
|
|
}
|
|
|
|
public function register(): void
|
|
{
|
|
$providers = config('source-control.providers');
|
|
|
|
$providers[$this->name] = [
|
|
'label' => $this->label,
|
|
'handler' => $this->handler,
|
|
'form' => $this->form ? $this->form->toArray() : [],
|
|
];
|
|
|
|
config(['source-control.providers' => $providers]);
|
|
}
|
|
}
|