Plugins base (#613)

* wip

* wip

* cleanup

* notification channels

* phpstan

* services

* remove server types

* refactoring

* refactoring
This commit is contained in:
Saeed Vaziry
2025-06-14 14:35:18 +02:00
committed by GitHub
parent adc0653d15
commit 131b828807
311 changed files with 3976 additions and 2660 deletions

View File

@ -0,0 +1,54 @@
<?php
namespace App\Plugins;
use RuntimeException;
class RegisterSiteFeature
{
public function __construct(
public string $type,
public string $name,
public string $label = '',
public string $description = ''
) {}
public static function make(string $type, string $name): self
{
return new self($type, $name);
}
public function label(string $label): self
{
$this->label = $label;
return $this;
}
public function description(string $description): self
{
$this->description = $description;
return $this;
}
public function register(): void
{
if (! config()->has('site.types.'.$this->type)) {
throw new RuntimeException('Site types not found');
}
$features = config('site.types.'.$this->type.'.features') ?? [];
if (isset($features[$this->name])) {
throw new RuntimeException("Feature '{$this->name}' already exists for type '{$this->type}'");
}
$features[$this->name] = [
'label' => $this->label,
'description' => $this->description,
];
config(['site.types.'.$this->type.'.features' => $features]);
}
}