mirror of
https://github.com/vitodeploy/vito.git
synced 2025-07-08 17:32:35 +00:00
Plugins base (#613)
* wip * wip * cleanup * notification channels * phpstan * services * remove server types * refactoring * refactoring
This commit is contained in:
61
app/Plugins/RegisterSourceControl.php
Normal file
61
app/Plugins/RegisterSourceControl.php
Normal file
@ -0,0 +1,61 @@
|
||||
<?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]);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user