feat : add Gitea settings API resource with provider/processor
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
30
src/State/GiteaSettingsProvider.php
Normal file
30
src/State/GiteaSettingsProvider.php
Normal file
@@ -0,0 +1,30 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace App\State;
|
||||
|
||||
use ApiPlatform\Metadata\Operation;
|
||||
use ApiPlatform\State\ProviderInterface;
|
||||
use App\ApiResource\GiteaSettings;
|
||||
use App\Repository\GiteaConfigurationRepository;
|
||||
|
||||
final readonly class GiteaSettingsProvider implements ProviderInterface
|
||||
{
|
||||
public function __construct(
|
||||
private GiteaConfigurationRepository $configRepository,
|
||||
) {}
|
||||
|
||||
public function provide(Operation $operation, array $uriVariables = [], array $context = []): GiteaSettings
|
||||
{
|
||||
$config = $this->configRepository->findSingleton();
|
||||
$dto = new GiteaSettings();
|
||||
|
||||
if (null !== $config) {
|
||||
$dto->url = $config->getUrl();
|
||||
$dto->hasToken = $config->hasToken();
|
||||
}
|
||||
|
||||
return $dto;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user