[ERP-74] Seed RBAC idempotent (rôles + matrice § 2.7 + demo users) + RG-1.04 + test matrice #40
@@ -83,6 +83,19 @@ final class ClientProcessor implements ProcessorInterface
|
|||||||
private const string PERM_ACCOUNTING_MANAGE = 'commercial.clients.accounting.manage';
|
private const string PERM_ACCOUNTING_MANAGE = 'commercial.clients.accounting.manage';
|
||||||
private const string PERM_ARCHIVE = 'commercial.clients.archive';
|
private const string PERM_ARCHIVE = 'commercial.clients.archive';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Memoisation du dernier corps de requete decode, clos par le contenu brut.
|
||||||
|
* payloadKeys() est appele plusieurs fois par requete (writablePayloadKeys,
|
||||||
|
* categoriesChanged...) : on evite de rejouer json_decode a chaque appel. La
|
||||||
|
* cle etant le contenu lui-meme et le calcul une fonction pure de ce contenu,
|
||||||
|
* aucune fuite n'est possible entre requetes sur ce service partage (un meme
|
||||||
|
* corps redonne les memes cles).
|
||||||
|
*/
|
||||||
|
private ?string $decodedContent = null;
|
||||||
|
|
||||||
|
/** @var list<string> Cles de premier niveau correspondant au corps memoise. */
|
||||||
|
private array $decodedPayloadKeys = [];
|
||||||
|
|
||||||
public function __construct(
|
public function __construct(
|
||||||
#[Autowire(service: 'api_platform.doctrine.orm.state.persist_processor')]
|
#[Autowire(service: 'api_platform.doctrine.orm.state.persist_processor')]
|
||||||
private readonly ProcessorInterface $persistProcessor,
|
private readonly ProcessorInterface $persistProcessor,
|
||||||
@@ -576,6 +589,26 @@ final class ClientProcessor implements ProcessorInterface
|
|||||||
}
|
}
|
||||||
|
|
||||||
$content = $request->getContent();
|
$content = $request->getContent();
|
||||||
|
|
||||||
|
// Cache hit : meme corps brut que le dernier decodage -> memes cles.
|
||||||
|
if ($content === $this->decodedContent) {
|
||||||
|
return $this->decodedPayloadKeys;
|
||||||
|
}
|
||||||
|
|
||||||
|
$this->decodedContent = $content;
|
||||||
|
$this->decodedPayloadKeys = $this->extractPayloadKeys($content);
|
||||||
|
|
||||||
|
return $this->decodedPayloadKeys;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Decode le corps brut et en extrait les cles de premier niveau (chaines).
|
||||||
|
* Corps vide ou JSON invalide -> aucune cle.
|
||||||
|
*
|
||||||
|
* @return list<string>
|
||||||
|
*/
|
||||||
|
private function extractPayloadKeys(string $content): array
|
||||||
|
{
|
||||||
if ('' === $content) {
|
if ('' === $content) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user