|
| 1 | +<?php |
| 2 | + |
| 3 | +/* |
| 4 | + * This file is part of the API Platform project. |
| 5 | + * |
| 6 | + * (c) Kévin Dunglas <dunglas@gmail.com> |
| 7 | + * |
| 8 | + * For the full copyright and license information, please view the LICENSE |
| 9 | + * file that was distributed with this source code. |
| 10 | + */ |
| 11 | + |
| 12 | +declare(strict_types=1); |
| 13 | + |
| 14 | +namespace ApiPlatform\JsonApi\Serializer; |
| 15 | + |
| 16 | +use ApiPlatform\Metadata\IriConverterInterface; |
| 17 | +use ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface; |
| 18 | +use ApiPlatform\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface; |
| 19 | +use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface; |
| 20 | +use ApiPlatform\Metadata\ResourceAccessCheckerInterface; |
| 21 | +use ApiPlatform\Metadata\ResourceClassResolverInterface; |
| 22 | +use ApiPlatform\Serializer\AbstractItemNormalizer; |
| 23 | +use ApiPlatform\Serializer\OperationResourceClassResolverInterface; |
| 24 | +use ApiPlatform\Serializer\TagCollectorInterface; |
| 25 | +use Symfony\Component\PropertyAccess\PropertyAccessorInterface; |
| 26 | +use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface; |
| 27 | +use Symfony\Component\Serializer\NameConverter\NameConverterInterface; |
| 28 | + |
| 29 | +/** |
| 30 | + * Converts JSON:API documents to objects (denormalization only). |
| 31 | + * |
| 32 | + * @author Kévin Dunglas <dunglas@gmail.com> |
| 33 | + * @author Amrouche Hamza <hamza.simperfit@gmail.com> |
| 34 | + * @author Baptiste Meyer <baptiste.meyer@gmail.com> |
| 35 | + */ |
| 36 | +final class ItemDenormalizer extends AbstractItemNormalizer |
| 37 | +{ |
| 38 | + use ItemNormalizerTrait; |
| 39 | + |
| 40 | + public const FORMAT = 'jsonapi'; |
| 41 | + |
| 42 | + public function __construct( |
| 43 | + PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory, |
| 44 | + PropertyMetadataFactoryInterface $propertyMetadataFactory, |
| 45 | + IriConverterInterface $iriConverter, |
| 46 | + ResourceClassResolverInterface $resourceClassResolver, |
| 47 | + ?PropertyAccessorInterface $propertyAccessor = null, |
| 48 | + ?NameConverterInterface $nameConverter = null, |
| 49 | + ?ClassMetadataFactoryInterface $classMetadataFactory = null, |
| 50 | + array $defaultContext = [], |
| 51 | + ?ResourceMetadataCollectionFactoryInterface $resourceMetadataCollectionFactory = null, |
| 52 | + ?ResourceAccessCheckerInterface $resourceAccessChecker = null, |
| 53 | + protected ?TagCollectorInterface $tagCollector = null, |
| 54 | + ?OperationResourceClassResolverInterface $operationResourceResolver = null, |
| 55 | + private readonly bool $useIriAsId = true, |
| 56 | + ) { |
| 57 | + parent::__construct($propertyNameCollectionFactory, $propertyMetadataFactory, $iriConverter, $resourceClassResolver, $propertyAccessor, $nameConverter, $classMetadataFactory, $defaultContext, $resourceMetadataCollectionFactory, $resourceAccessChecker, $tagCollector, $operationResourceResolver); |
| 58 | + } |
| 59 | + |
| 60 | + public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool |
| 61 | + { |
| 62 | + return false; |
| 63 | + } |
| 64 | +} |
0 commit comments