denormalizers are no longer aliased as normalizer in 4.4
まだ誰も着手していません。
評価
- 難易度
- 3/5
- 見積もり時間
- 1〜2日
- 初心者へのやさしさ
- 68/100
調査の方向性
Start by reviewing commit d36c14c and the service IDs api_platform.jsonld.normalizer.item and api_platform.jsonld.denormalizer.item. Reproduce the issue with the DTO and decorator shown, then verify that decorating the normalizer also affects denormalization as it did in 4.3, without requiring a second decorator.
索引モデルが issue の本文から書いたものです。
説明
API Platform version(s) affected: 4.4.0
Description
Commit d36c14c splits normalizer and denormalizer into dedicated ItemNormalizer and ItemDenormalizer. This causes overwritten decorators to no longer work (docs is also still outdated https://api-platform.com/docs/v4.4/core/serialization/#decorating-a-serializer-and-adding-extra-data-for-symfony)
How to reproduce
Create a serializer that decorates only 'api_platform.jsonld.normalizer.item', it no longer decorates during denormalize.
// small DTO to play with:
class Test
{
public bool $test = false;
}
#[AsDecorator('api_platform.jsonld.normalizer.item')]
class ExampleSerializer implements NormalizerInterface, DenormalizerInterface, SerializerAwareInterface
{
public function __construct(
#[AutowireDecorated]
private readonly NormalizerInterface&DenormalizerInterface&SerializerAwareInterface $decorated,
) {
}
public function setSerializer(SerializerInterface $serializer): void
{
$this->decorated->setSerializer($serializer);
}
public function denormalize(mixed $data, string $type, ?string $format = null, array $context = []): mixed
{
$result = $this->decorated->denormalize($data, $type, $format, $context);
$result->test = true;
return $result;
}
public function supportsDenormalization(
mixed $data,
string $type,
?string $format = null,
array $context = [],
): bool {
return $this->decorated->supportsDenormalization($data, $type, $format, $context);
}
public function normalize(
mixed $data,
?string $format = null,
array $context = [],
): array|string|int|float|bool|ArrayObject|null {
$result = $this->decorated->normalize($data, $format, $context);
$result['extraProperty'] = true;
return $result;
}
public function supportsNormalization(mixed $data, ?string $format = null, array $context = []): bool
{
return $this->decorated->supportsNormalization($data, $format, $context);
}
public function getSupportedTypes(?string $format): array
{
return $this->decorated->getSupportedTypes($format);
}
}
Given this setup, I expect normalize to add extraProperty and denormalize to set test to true. In 4.3 this worked, in 4.4 it no longer works and we have to add an extra decorator:
~ #[AsDecorator('api_platform.jsonld.normalizer.item')]
+ #[AsDecorator('api_platform.jsonld.denormalizer.item')]
~ class ExampleSerializer implements NormalizerInterface, DenormalizerInterface, SerializerAwareInterface
Hence why this is a backwards compatibility break on a minor version (4.4).
Possible Solution
d36c14c should be removed from 4.4 and moved to 5.0
Additional Context
- 主要言語
- PHP
- スター
- 2.6k
- フォーク
- 982
- 平均マージ
- 1日 16時間
- マージ済み PR(30日)
- 59
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
api-platform/core のほかの issue
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
api-platform/core#8573 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
api-platform/core#8571 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
api-platform/core#8564 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
api-platform/core#8495 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 85/100
api-platform/core#8471 ·
api-platform/core の issue をすべて見る
似ている issue
-
tooling
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
UX
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
ProfessionalWiki/NeoWiki#1525 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 1/5 1時間未満 初心者へのやさしさ 90/100
OpenConext/OpenConext-engineblock#2122 ·
-
Bug
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
Automattic/safe-publish#594 ·