Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

405
Views
Problema de referencia circular con servicio decorado

Como sugiere la documentación , escribí este servicio para agregar el uuid al objeto normalizado:

 <?php namespace App\Serializer; use InvalidArgumentException; use Symfony\Component\Serializer\Normalizer\DenormalizerInterface; use Symfony\Component\Serializer\Normalizer\NormalizerInterface; use Symfony\Component\Serializer\SerializerAwareInterface; use Symfony\Component\Serializer\SerializerInterface; final class ApiNormalizer implements NormalizerInterface, DenormalizerInterface, SerializerAwareInterface { private DenormalizerInterface|NormalizerInterface $decorated; public function __construct(NormalizerInterface $decorated) { if (!$decorated instanceof DenormalizerInterface) { throw new InvalidArgumentException(sprintf('The decorated normalizer must implement the %s.', DenormalizerInterface::class)); } $this->decorated = $decorated; } public function supportsNormalization($data, $format = null) { return $this->decorated->supportsNormalization($data, $format); } public function normalize($object, $format = null, array $context = []) { $data = $this->decorated->normalize($object, $format, $context); if(method_exists($object, 'getUuid') && is_array($data)){ $data['uuid'] = $object->getUuid(); } return $data; } /** * @param mixed $data * @param string $type * @param null $format * * @return bool */ public function supportsDenormalization($data, $type, $format = null) { return $this->decorated->supportsDenormalization($data, $type, $format); } public function denormalize($data, $type, $format = null, array $context = []) { return $this->decorated->denormalize($data, $type, $format, $context); } public function setSerializer(SerializerInterface $serializer) { if($this->decorated instanceof SerializerAwareInterface) { $this->decorated->setSerializer($serializer); } } }

Y services.yaml

 App\Serializer\ApiNormalizer: # By default .inner is passed as argument decorates: 'api_platform.jsonld.normalizer.item'

Pero de repente (hasta ayer todo iba bien) me empieza a dar este error cuando ejecuto composer o cache clear

En CheckCircularReferencesPass.php línea 67: se detectó una referencia circular para el servicio "App\Serializer\ApiNormalizer", ruta: "App\Serializer\ApiNormalizer -> serializer -> App\Serializer\ApiNormalizer".

over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Este es un problema con el componente Inyección de dependencia de Symfony en la versión 5.3.7.

https://github.com/symfony/symfony/issues/42792

Es probable que esto se resuelva mañana o pasado.

Mientras tanto, simplemente agregue esto a su composer.json :

 "conflict": { "symfony/dependency-injection": "5.3.7" },

De esta manera, puede mantener actualizadas el resto de las dependencias, y solo excluirá DI 5.3.7 a favor de 5.3.6.

Cuando se lance 5.3.8, podrá actualizar directamente.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!