Files
Lesstime/src/Module/Integration/Infrastructure/ApiPlatform/State/GiteaSettingsProcessor.php
T
Matthieu da3d190216 refactor(core) : final legacy cleanup — app is 100% modular
LST-60 (3.3). Closes the modular-monolith migration. src/Entity was already
empty; this removes the last legacy residue.

- Doctrine: drop the legacy "App" mapping (empty src/Entity). resolve_target_
  entities already targets modules only.
- MCP User tools (Reference/) -> Core/Infrastructure/Mcp/Tool; MCP Serializer
  -> Shared/Infrastructure/Mcp (33 usages repointed).
- Controllers (mark-all-read, notification unread-count, regenerate-api-token,
  user-avatar) -> Core/Infrastructure/Controller. TokenEncryptor -> Shared/
  Infrastructure/Service (11 usages). AppVersion resource+provider -> Shared.
  ContractType enum -> Core/Domain/Enum.
- src/{Entity,State,Controller,Service,Enum,ApiResource} now empty; routes,
  MCP tool names and public API unchanged.

180 tests green, mapping valid, no route regression, cs-fixer clean.
Note: final Malio visual harmonisation (subjective) left to the PO.
2026-06-21 01:25:19 +02:00

48 lines
1.5 KiB
PHP

<?php
declare(strict_types=1);
namespace App\Module\Integration\Infrastructure\ApiPlatform\State;
use ApiPlatform\Metadata\Operation;
use ApiPlatform\State\ProcessorInterface;
use App\Module\Integration\Domain\Entity\GiteaConfiguration;
use App\Module\Integration\Domain\Repository\GiteaConfigurationRepositoryInterface;
use App\Module\Integration\Infrastructure\ApiPlatform\Resource\GiteaSettings;
use App\Shared\Infrastructure\Service\TokenEncryptor;
use Doctrine\ORM\EntityManagerInterface;
final readonly class GiteaSettingsProcessor implements ProcessorInterface
{
public function __construct(
private EntityManagerInterface $em,
private GiteaConfigurationRepositoryInterface $configRepository,
private TokenEncryptor $tokenEncryptor,
) {}
public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []): GiteaSettings
{
assert($data instanceof GiteaSettings);
$config = $this->configRepository->findSingleton();
if (null === $config) {
$config = new GiteaConfiguration();
}
$config->setUrl($data->url);
if (null !== $data->token && '' !== $data->token) {
$config->setEncryptedToken($this->tokenEncryptor->encrypt($data->token));
}
$this->em->persist($config);
$this->em->flush();
$result = new GiteaSettings();
$result->url = $config->getUrl();
$result->hasToken = $config->hasToken();
return $result;
}
}