• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

api-platform / core / 16531587208

25 Jul 2025 09:05PM UTC coverage: 0.0% (-22.1%) from 22.07%
16531587208

Pull #7225

github

web-flow
Merge 23f449a58 into 02a764950
Pull Request #7225: feat: json streamer

0 of 294 new or added lines in 31 files covered. (0.0%)

11514 existing lines in 375 files now uncovered.

0 of 51976 relevant lines covered (0.0%)

0.0 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/JsonLd/JsonStreamer/WritePropertyMetadataLoader.php
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\JsonLd\JsonStreamer;
15

16
use ApiPlatform\Hydra\Collection;
17
use ApiPlatform\Hydra\IriTemplate;
18
use ApiPlatform\Metadata\ResourceClassResolverInterface;
19
use ApiPlatform\Metadata\Util\TypeHelper;
20
use Symfony\Component\JsonStreamer\Mapping\PropertyMetadata;
21
use Symfony\Component\JsonStreamer\Mapping\PropertyMetadataLoaderInterface;
22
use Symfony\Component\TypeInfo\Type;
23

24
final class WritePropertyMetadataLoader implements PropertyMetadataLoaderInterface
25
{
26
    public function __construct(
27
        private readonly PropertyMetadataLoaderInterface $loader,
28
        private readonly ResourceClassResolverInterface $resourceClassResolver,
29
    ) {
NEW
30
    }
×
31

32
    public function load(string $className, array $options = [], array $context = []): array
33
    {
NEW
34
        $properties = $this->loader->load($className, $options, $context);
×
35

NEW
36
        if (IriTemplate::class === $className) {
×
NEW
37
            $properties['template'] = new PropertyMetadata(
×
NEW
38
                'template',
×
NEW
39
                Type::string(),
×
NEW
40
                ['api_platform.hydra.json_streamer.write.value_transformer.template'],
×
NEW
41
            );
×
42

NEW
43
            return $properties;
×
44
        }
45

NEW
46
        if (Collection::class !== $className && !$this->resourceClassResolver->isResourceClass($className)) {
×
NEW
47
            return $properties;
×
48
        }
49

NEW
50
        $properties['@id'] = new PropertyMetadata(
×
NEW
51
            'id', // virtual property
×
NEW
52
            Type::mixed(), // virtual property
×
NEW
53
            ['api_platform.jsonld.json_streamer.write.value_transformer.iri'],
×
NEW
54
        );
×
55

NEW
56
        $properties['@type'] = new PropertyMetadata(
×
NEW
57
            'id', // virtual property
×
NEW
58
            Type::mixed(), // virtual property
×
NEW
59
            ['api_platform.jsonld.json_streamer.write.value_transformer.type'],
×
NEW
60
        );
×
61

NEW
62
        $originalClassName = TypeHelper::getClassName($context['original_type']);
×
63

NEW
64
        if (Collection::class === $originalClassName || ($this->resourceClassResolver->isResourceClass($originalClassName) && !isset($context['generated_classes'][Collection::class]))) {
×
NEW
65
            $properties['@context'] = new PropertyMetadata(
×
NEW
66
                'id', // virual property
×
NEW
67
                Type::string(), // virtual property
×
NEW
68
                ['api_platform.jsonld.json_streamer.write.value_transformer.context'],
×
NEW
69
            );
×
70
        }
71

NEW
72
        return $properties;
×
73
    }
74
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc