feat : add Gitea settings API resource with provider/processor
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
42
src/ApiResource/GiteaSettings.php
Normal file
42
src/ApiResource/GiteaSettings.php
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\ApiResource;
|
||||
|
||||
use ApiPlatform\Metadata\ApiResource;
|
||||
use ApiPlatform\Metadata\Get;
|
||||
use ApiPlatform\Metadata\Put;
|
||||
use App\State\GiteaSettingsProcessor;
|
||||
use App\State\GiteaSettingsProvider;
|
||||
use Symfony\Component\Serializer\Attribute\Groups;
|
||||
|
||||
#[ApiResource(
|
||||
operations: [
|
||||
new Get(
|
||||
uriTemplate: '/settings/gitea',
|
||||
normalizationContext: ['groups' => ['gitea_settings:read']],
|
||||
provider: GiteaSettingsProvider::class,
|
||||
security: "is_granted('ROLE_ADMIN')",
|
||||
),
|
||||
new Put(
|
||||
uriTemplate: '/settings/gitea',
|
||||
denormalizationContext: ['groups' => ['gitea_settings:write']],
|
||||
normalizationContext: ['groups' => ['gitea_settings:read']],
|
||||
provider: GiteaSettingsProvider::class,
|
||||
processor: GiteaSettingsProcessor::class,
|
||||
security: "is_granted('ROLE_ADMIN')",
|
||||
),
|
||||
],
|
||||
)]
|
||||
final class GiteaSettings
|
||||
{
|
||||
#[Groups(['gitea_settings:read', 'gitea_settings:write'])]
|
||||
public ?string $url = null;
|
||||
|
||||
#[Groups(['gitea_settings:write'])]
|
||||
public ?string $token = null;
|
||||
|
||||
#[Groups(['gitea_settings:read'])]
|
||||
public bool $hasToken = false;
|
||||
}
|
||||
Reference in New Issue
Block a user