fix: SonarQube - VaultService constante + exception dediee, labels accessibles
VaultService : - Constante TRANSIT_KEYS_PATH pour literal duplique 5 fois - VaultException dediee au lieu de RuntimeException generique - Factory method VaultException::httpError(statusCode, body) Templates accessibilite (labels for=) : - prestataires/show.html.twig : 13 labels (edit form + add facture modal) - prestataires/index.html.twig : 8 labels (SIRET search + create modal) - revendeurs/create.html.twig : 1 label (checkbox isUseStripe) - revendeurs/edit.html.twig : 1 label (checkbox isUseStripe) Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
11
src/Exception/VaultException.php
Normal file
11
src/Exception/VaultException.php
Normal file
@@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
namespace App\Exception;
|
||||
|
||||
class VaultException extends \RuntimeException
|
||||
{
|
||||
public static function httpError(int $statusCode, string $body): self
|
||||
{
|
||||
return new self('Vault HTTP '.$statusCode.': '.$body);
|
||||
}
|
||||
}
|
||||
@@ -2,12 +2,14 @@
|
||||
|
||||
namespace App\Service;
|
||||
|
||||
use App\Exception\VaultException;
|
||||
use Psr\Log\LoggerInterface;
|
||||
use Symfony\Component\DependencyInjection\Attribute\Autowire;
|
||||
use Symfony\Contracts\HttpClient\HttpClientInterface;
|
||||
|
||||
class VaultService
|
||||
{
|
||||
private const TRANSIT_KEYS_PATH = '/v1/transit/keys/';
|
||||
public function __construct(
|
||||
private HttpClientInterface $httpClient,
|
||||
private LoggerInterface $logger,
|
||||
@@ -33,7 +35,7 @@ class VaultService
|
||||
}
|
||||
|
||||
try {
|
||||
$this->request('POST', '/v1/transit/keys/'.$keyName, ['type' => $type]);
|
||||
$this->request('POST', self::TRANSIT_KEYS_PATH.$keyName, ['type' => $type]);
|
||||
|
||||
$this->logger->info('Vault: cle creee: '.$keyName);
|
||||
|
||||
@@ -56,9 +58,9 @@ class VaultService
|
||||
|
||||
try {
|
||||
// Marquer comme supprimable
|
||||
$this->request('POST', '/v1/transit/keys/'.$keyName.'/config', ['deletion_allowed' => true]);
|
||||
$this->request('POST', self::TRANSIT_KEYS_PATH.$keyName.'/config', ['deletion_allowed' => true]);
|
||||
// Supprimer
|
||||
$this->request('DELETE', '/v1/transit/keys/'.$keyName);
|
||||
$this->request('DELETE', self::TRANSIT_KEYS_PATH.$keyName);
|
||||
|
||||
$this->logger->info('Vault: cle supprimee: '.$keyName);
|
||||
|
||||
@@ -82,7 +84,7 @@ class VaultService
|
||||
}
|
||||
|
||||
try {
|
||||
$this->request('POST', '/v1/transit/keys/'.$keyName.'/config', $config);
|
||||
$this->request('POST', self::TRANSIT_KEYS_PATH.$keyName.'/config', $config);
|
||||
|
||||
return true;
|
||||
} catch (\Throwable $e) {
|
||||
@@ -104,7 +106,7 @@ class VaultService
|
||||
}
|
||||
|
||||
try {
|
||||
$data = $this->request('LIST', '/v1/transit/keys');
|
||||
$data = $this->request('LIST', self::TRANSIT_KEYS_PATH);
|
||||
|
||||
return $data['data']['keys'] ?? [];
|
||||
} catch (\Throwable) {
|
||||
@@ -122,7 +124,7 @@ class VaultService
|
||||
}
|
||||
|
||||
try {
|
||||
$this->request('GET', '/v1/transit/keys/'.$keyName);
|
||||
$this->request('GET', self::TRANSIT_KEYS_PATH.$keyName);
|
||||
|
||||
return true;
|
||||
} catch (\Throwable) {
|
||||
@@ -216,7 +218,7 @@ class VaultService
|
||||
$response = $this->httpClient->request($method, rtrim($this->vaultUrl, '/').$path, $options);
|
||||
|
||||
if ($response->getStatusCode() >= 400) {
|
||||
throw new \RuntimeException('Vault HTTP '.$response->getStatusCode().': '.$response->getContent(false));
|
||||
throw VaultException::httpError($response->getStatusCode(), $response->getContent(false));
|
||||
}
|
||||
|
||||
$content = $response->getContent(false);
|
||||
|
||||
@@ -72,7 +72,7 @@
|
||||
<form method="post" action="{{ path('app_admin_prestataires_create') }}">
|
||||
{# Recherche SIRET #}
|
||||
<div class="mb-4 p-3 bg-gray-50 border border-gray-200">
|
||||
<label class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Recherche par SIRET ou nom</label>
|
||||
<label for="siret-search-input" class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Recherche par SIRET ou nom</label>
|
||||
<div class="flex gap-2 relative">
|
||||
<input type="text" id="siret-search-input" placeholder="SIRET, nom ou raison sociale..." class="input-glass flex-1 px-3 py-2 text-xs font-bold">
|
||||
<button type="button" id="siret-search-btn" class="px-4 py-2 bg-gray-900 text-white hover:bg-[#fabf04] hover:text-gray-900 font-bold uppercase text-[10px] tracking-wider transition-all">Rechercher</button>
|
||||
@@ -82,32 +82,32 @@
|
||||
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-3 mb-4">
|
||||
<div class="md:col-span-2">
|
||||
<label class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Raison sociale *</label>
|
||||
<input type="text" name="raisonSociale" required class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
<label for="presta-create-raisonSociale" class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Raison sociale *</label>
|
||||
<input type="text" id="presta-create-raisonSociale" name="raisonSociale" required class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">SIRET</label>
|
||||
<input type="text" name="siret" maxlength="14" class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
<label for="presta-create-siret" class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">SIRET</label>
|
||||
<input type="text" id="presta-create-siret" name="siret" maxlength="14" class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Email</label>
|
||||
<input type="email" name="email" class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
<label for="presta-create-email" class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Email</label>
|
||||
<input type="email" id="presta-create-email" name="email" class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Telephone</label>
|
||||
<input type="text" name="phone" class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
<label for="presta-create-phone" class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Telephone</label>
|
||||
<input type="text" id="presta-create-phone" name="phone" class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Adresse</label>
|
||||
<input type="text" name="address" class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
<label for="presta-create-address" class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Adresse</label>
|
||||
<input type="text" id="presta-create-address" name="address" class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Code postal</label>
|
||||
<input type="text" name="zipCode" maxlength="10" class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
<label for="presta-create-zipCode" class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Code postal</label>
|
||||
<input type="text" id="presta-create-zipCode" name="zipCode" maxlength="10" class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Ville</label>
|
||||
<input type="text" name="city" class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
<label for="presta-create-city" class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Ville</label>
|
||||
<input type="text" id="presta-create-city" name="city" class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-end gap-2">
|
||||
|
||||
@@ -32,32 +32,32 @@
|
||||
<form method="post" action="{{ path('app_admin_prestataires_edit', {id: prestataire.id}) }}">
|
||||
<div class="grid grid-cols-1 md:grid-cols-3 gap-3 mb-4">
|
||||
<div>
|
||||
<label class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Raison sociale</label>
|
||||
<input type="text" name="raisonSociale" value="{{ prestataire.raisonSociale }}" required class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
<label for="presta-edit-raisonSociale" class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Raison sociale</label>
|
||||
<input type="text" id="presta-edit-raisonSociale" name="raisonSociale" value="{{ prestataire.raisonSociale }}" required class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">SIRET</label>
|
||||
<input type="text" name="siret" value="{{ prestataire.siret }}" maxlength="14" class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
<label for="presta-edit-siret" class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">SIRET</label>
|
||||
<input type="text" id="presta-edit-siret" name="siret" value="{{ prestataire.siret }}" maxlength="14" class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Email</label>
|
||||
<input type="email" name="email" value="{{ prestataire.email }}" class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
<label for="presta-edit-email" class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Email</label>
|
||||
<input type="email" id="presta-edit-email" name="email" value="{{ prestataire.email }}" class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Telephone</label>
|
||||
<input type="text" name="phone" value="{{ prestataire.phone }}" class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
<label for="presta-edit-phone" class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Telephone</label>
|
||||
<input type="text" id="presta-edit-phone" name="phone" value="{{ prestataire.phone }}" class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Adresse</label>
|
||||
<input type="text" name="address" value="{{ prestataire.address }}" class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
<label for="presta-edit-address" class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Adresse</label>
|
||||
<input type="text" id="presta-edit-address" name="address" value="{{ prestataire.address }}" class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Code postal</label>
|
||||
<input type="text" name="zipCode" value="{{ prestataire.zipCode }}" maxlength="10" class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
<label for="presta-edit-zipCode" class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Code postal</label>
|
||||
<input type="text" id="presta-edit-zipCode" name="zipCode" value="{{ prestataire.zipCode }}" maxlength="10" class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Ville</label>
|
||||
<input type="text" name="city" value="{{ prestataire.city }}" class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
<label for="presta-edit-city" class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Ville</label>
|
||||
<input type="text" id="presta-edit-city" name="city" value="{{ prestataire.city }}" class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex gap-2">
|
||||
@@ -146,32 +146,32 @@
|
||||
<form method="post" action="{{ path('app_admin_prestataires_facture_add', {id: prestataire.id}) }}" enctype="multipart/form-data">
|
||||
<div class="grid grid-cols-1 md:grid-cols-2 gap-3 mb-4">
|
||||
<div class="md:col-span-2">
|
||||
<label class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">N Facture *</label>
|
||||
<input type="text" name="numFacture" required class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
<label for="presta-add-numFacture" class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">N Facture *</label>
|
||||
<input type="text" id="presta-add-numFacture" name="numFacture" required class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Mois *</label>
|
||||
<select name="month" required class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
<label for="presta-add-month" class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Mois *</label>
|
||||
<select id="presta-add-month" name="month" required class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
{% for m in 1..12 %}
|
||||
<option value="{{ m }}" {{ m == "now"|date("n") ? 'selected' }}>{{ m }} - {{ ["Janvier","Fevrier","Mars","Avril","Mai","Juin","Juillet","Aout","Septembre","Octobre","Novembre","Decembre"][m-1] }}</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Annee *</label>
|
||||
<input type="number" name="year" value="{{ "now"|date("Y") }}" min="2020" max="2099" required class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
<label for="presta-add-year" class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Annee *</label>
|
||||
<input type="number" id="presta-add-year" name="year" value="{{ "now"|date("Y") }}" min="2020" max="2099" required class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Montant HT</label>
|
||||
<input type="number" name="montantHt" step="0.01" min="0" value="0.00" class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
<label for="presta-add-montantHt" class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Montant HT</label>
|
||||
<input type="number" id="presta-add-montantHt" name="montantHt" step="0.01" min="0" value="0.00" class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
</div>
|
||||
<div>
|
||||
<label class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Montant TTC</label>
|
||||
<input type="number" name="montantTtc" step="0.01" min="0" value="0.00" class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
<label for="presta-add-montantTtc" class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Montant TTC</label>
|
||||
<input type="number" id="presta-add-montantTtc" name="montantTtc" step="0.01" min="0" value="0.00" class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
</div>
|
||||
<div class="md:col-span-2">
|
||||
<label class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Fichier PDF</label>
|
||||
<input type="file" name="facturePdf" accept=".pdf" class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
<label for="presta-add-facturePdf" class="block text-[9px] font-bold uppercase tracking-wider text-gray-400 mb-1">Fichier PDF</label>
|
||||
<input type="file" id="presta-add-facturePdf" name="facturePdf" accept=".pdf" class="input-glass w-full px-3 py-2 text-xs font-bold">
|
||||
</div>
|
||||
</div>
|
||||
<div class="flex justify-end gap-2">
|
||||
|
||||
@@ -86,8 +86,8 @@
|
||||
|
||||
<section class="glass p-6">
|
||||
<h2 class="text-sm font-bold uppercase tracking-wider mb-4">Options</h2>
|
||||
<label class="flex items-center gap-2 cursor-pointer">
|
||||
<input type="checkbox" name="isUseStripe" value="1" class="accent-[#fabf04]">
|
||||
<label for="rev-create-isUseStripe" class="flex items-center gap-2 cursor-pointer">
|
||||
<input type="checkbox" id="rev-create-isUseStripe" name="isUseStripe" value="1" class="accent-[#fabf04]">
|
||||
<span class="text-xs font-bold">Activer Stripe Connect</span>
|
||||
</label>
|
||||
</section>
|
||||
|
||||
@@ -72,8 +72,8 @@
|
||||
|
||||
<section class="glass p-6">
|
||||
<h2 class="text-sm font-bold uppercase tracking-wider mb-4">Options</h2>
|
||||
<label class="flex items-center gap-2 cursor-pointer">
|
||||
<input type="checkbox" name="isUseStripe" value="1" {{ revendeur.isUseStripe ? 'checked' }} class="accent-[#fabf04]">
|
||||
<label for="rev-edit-isUseStripe" class="flex items-center gap-2 cursor-pointer">
|
||||
<input type="checkbox" id="rev-edit-isUseStripe" name="isUseStripe" value="1" {{ revendeur.isUseStripe ? 'checked' }} class="accent-[#fabf04]">
|
||||
<span class="text-xs font-bold">Activer Stripe Connect</span>
|
||||
</label>
|
||||
{% if revendeur.stripeConnectId %}
|
||||
|
||||
Reference in New Issue
Block a user