onChange = $onChange; } #[Required] public function setProcessorInterface(ProcessorInterface $persistProcessor): void {$this->persistProcessor = $persistProcessor;} /** * Persiste l'entité et déclenche les différents hooks de la classe OnChangeInterface définie par le data persister * * @param mixed $data * @param Operation $operation * @param mixed[] $uriVariables * @param mixed[] $context * @return object */ public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []): object { if($operation instanceof Delete){ throw new RuntimeException('not supported', Response::HTTP_METHOD_NOT_ALLOWED); } if($operation instanceof Put){ throw new RuntimeException('not supported', Response::HTTP_METHOD_NOT_ALLOWED); } $onChangeContext = new OnChangeContext($context); $this->onChange->validate($data, $onChangeContext); $data = $this->onChange->preProcess($data, $onChangeContext); $this->onChange->beforeChange($data, $onChangeContext); $result = $this->persistProcessor->process($data, $operation, $uriVariables, $context); $this->onChange->onChange($data, $onChangeContext); return $result; } }