In API Platform, I am trying to decorate the service api_platform.jsonld.normalizer.item (class ApiPlatformJsonLdSerializerItemNormalizer).
I notice this is causing some strange behavior in my application. For example, I get an error Specified class AppDtoFileFileMultipleResponseDto is not a resource class. which is not showing before setting up the decorator.
Here is my decorator :
<?php
declare(strict_types=1);
namespace AppSerializer;
use SymfonyComponentDependencyInjectionAttributeAsDecorator;
use SymfonyComponentSerializerExceptionLogicException;
use SymfonyComponentSerializerNormalizerCacheableSupportsMethodInterface;
use SymfonyComponentSerializerNormalizerDenormalizerInterface;
use SymfonyComponentSerializerNormalizerNormalizerInterface;
use SymfonyComponentSerializerSerializerAwareInterface;
use SymfonyComponentSerializerSerializerInterface;
#[AsDecorator('api_platform.jsonld.normalizer.item')]
class ItemJsonLdNormalizer implements NormalizerInterface, DenormalizerInterface, SerializerAwareInterface, CacheableSupportsMethodInterface
{
public function __construct(
private readonly NormalizerInterface $normalizer,
) {}
public function normalize(mixed $object, string $format = null, array $context = []): array|string|int|float|bool|ArrayObject|null
{
return $this->normalizer->normalize($object, $format, $context);
}
public function supportsDenormalization(mixed $data, string $type, string $format = null, array $context = []): bool
{
return $this->normalizer->supportsDenormalization($data, $type, $format, $context);
}
public function denormalize(mixed $data, string $type, string $format = null, array $context = []): mixed
{
return $this->normalizer->denormalize($data, $type, $format, $context);
}
public function hasCacheableSupportsMethod(): bool
{
return $this->normalizer->hasCacheableSupportsMethod();
}
public function supportsNormalization(mixed $data, string $format = null)
{
return $this->normalizer->supportsNormalization($data, $format);
}
public function setSerializer(SerializerInterface $serializer)
{
return $this->normalizer->setSerializer($serializer);
}
}
As you can see, it’s currently doing nothing appart from decorating the original service.
What am I doing wrong ?