Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .commitlintrc
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
"graphql",
"hal",
"httpcache",
"httpcache",
"hydra",
"jsonapi",
"jsonld",
Expand All @@ -26,6 +25,7 @@
"state",
"symfony",
"test",
"toon",
"validator",
]
],
Expand Down
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,7 @@
"api-platform/serializer": "self.version",
"api-platform/state": "self.version",
"api-platform/symfony": "self.version",
"api-platform/toon": "self.version",
"api-platform/validator": "self.version"
},
"require": {
Expand Down Expand Up @@ -137,6 +138,7 @@
"friends-of-behat/symfony-extension": "^2.1",
"friendsofphp/php-cs-fixer": "^3.93",
"guzzlehttp/guzzle": "^6.0 || ^7.0",
"helgesverre/toon": "^3.1",
"illuminate/config": "^11.0 || ^12.0 || ^13.0",
"illuminate/contracts": "^11.0 || ^12.0 || ^13.0",
"illuminate/database": "^11.0 || ^12.0 || ^13.0",
Expand Down Expand Up @@ -202,6 +204,7 @@
"suggest": {
"doctrine/mongodb-odm-bundle": "To support MongoDB. Only versions 4.0 and later are supported.",
"elasticsearch/elasticsearch": "To support Elasticsearch.",
"helgesverre/toon": "To support Toon format serialization.",
"opensearch-project/opensearch-php": "To support OpenSearch (^2.5).",
"phpstan/phpdoc-parser": "To support extracting metadata from PHPDoc.",
"psr/cache-implementation": "To use metadata caching.",
Expand Down
64 changes: 64 additions & 0 deletions src/JsonApi/Serializer/ItemDenormalizer.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
<?php

/*
* This file is part of the API Platform project.
*
* (c) Kévin Dunglas <dunglas@gmail.com>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/

declare(strict_types=1);

namespace ApiPlatform\JsonApi\Serializer;

use ApiPlatform\Metadata\IriConverterInterface;
use ApiPlatform\Metadata\Property\Factory\PropertyMetadataFactoryInterface;
use ApiPlatform\Metadata\Property\Factory\PropertyNameCollectionFactoryInterface;
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
use ApiPlatform\Metadata\ResourceAccessCheckerInterface;
use ApiPlatform\Metadata\ResourceClassResolverInterface;
use ApiPlatform\Serializer\AbstractItemNormalizer;
use ApiPlatform\Serializer\OperationResourceClassResolverInterface;
use ApiPlatform\Serializer\TagCollectorInterface;
use Symfony\Component\PropertyAccess\PropertyAccessorInterface;
use Symfony\Component\Serializer\Mapping\Factory\ClassMetadataFactoryInterface;
use Symfony\Component\Serializer\NameConverter\NameConverterInterface;

/**
* Converts JSON:API documents to objects (denormalization only).
*
* @author Kévin Dunglas <dunglas@gmail.com>
* @author Amrouche Hamza <hamza.simperfit@gmail.com>
* @author Baptiste Meyer <baptiste.meyer@gmail.com>
*/
final class ItemDenormalizer extends AbstractItemNormalizer
{
use ItemNormalizerTrait;

public const FORMAT = 'jsonapi';

public function __construct(
PropertyNameCollectionFactoryInterface $propertyNameCollectionFactory,
PropertyMetadataFactoryInterface $propertyMetadataFactory,
IriConverterInterface $iriConverter,
ResourceClassResolverInterface $resourceClassResolver,
?PropertyAccessorInterface $propertyAccessor = null,
?NameConverterInterface $nameConverter = null,
?ClassMetadataFactoryInterface $classMetadataFactory = null,
array $defaultContext = [],
?ResourceMetadataCollectionFactoryInterface $resourceMetadataCollectionFactory = null,
?ResourceAccessCheckerInterface $resourceAccessChecker = null,
protected ?TagCollectorInterface $tagCollector = null,
?OperationResourceClassResolverInterface $operationResourceResolver = null,
private readonly bool $useIriAsId = true,
) {
parent::__construct($propertyNameCollectionFactory, $propertyMetadataFactory, $iriConverter, $resourceClassResolver, $propertyAccessor, $nameConverter, $classMetadataFactory, $defaultContext, $resourceMetadataCollectionFactory, $resourceAccessChecker, $tagCollector, $operationResourceResolver);
}

public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
{
return false;
}
}
Loading
Loading