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

api-platform / core / 19235588366

10 Nov 2025 02:48PM UTC coverage: 0.0%. Remained the same
19235588366

Pull #7521

github

web-flow
Merge c4406a036 into 70611b397
Pull Request #7521: fix(state): create PUT has relation with lazy mapper

0 of 69 new or added lines in 6 files covered. (0.0%)

34 existing lines in 5 files now uncovered.

0 of 56734 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/State/Processor/ObjectMapperProcessor.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\State\Processor;
15

16
use ApiPlatform\Metadata\Operation;
17
use ApiPlatform\State\ProcessorInterface;
18
use Symfony\Component\ObjectMapper\Attribute\Map;
19
use Symfony\Component\ObjectMapper\Metadata\ObjectMapperMetadataFactoryInterface;
20
use Symfony\Component\ObjectMapper\ObjectMapperInterface;
21

22
/**
23
 * @implements ProcessorInterface<mixed,mixed>
24
 */
25
final class ObjectMapperProcessor implements ProcessorInterface
26
{
27
    /**
28
     * @param ProcessorInterface<mixed,mixed> $decorated
29
     */
30
    public function __construct(
31
        private readonly ?ObjectMapperInterface $objectMapper,
32
        private readonly ProcessorInterface $decorated,
33
        private readonly ?ObjectMapperMetadataFactoryInterface $objectMapperMetadata = null,
34
    ) {
35
        // TODO: 4.3 add this deprecation
36
        // if (!$objectMapperMetadata) {
37
        //     trigger_deprecation('api-platform/state', '4.3', 'Not injecting "%s" in "%s" will not be possible anymore in 4.4.', ObjectMapperMetadataFactoryInterface::class, __CLASS__);
38
        // }
UNCOV
39
    }
×
40

41
    public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []): object|array|null
42
    {
43
        if (
NEW
44
            !$this->objectMapper
×
45
            || !$operation->canWrite()
×
46
            || null === $data
×
47
            || !is_a($data, $operation->getClass(), true)
×
48
        ) {
NEW
49
            return $this->decorated->process($data, $operation, $uriVariables, $context);
×
50
        }
51

UNCOV
52
        if ($this->objectMapperMetadata) {
×
UNCOV
53
            if (!$this->objectMapperMetadata->create($data)) {
×
NEW
54
                return $this->decorated->process($data, $operation, $uriVariables, $context);
×
55
            }
NEW
56
        } elseif (!(new \ReflectionClass($operation->getClass()))->getAttributes(Map::class)) {
×
NEW
57
            return $this->decorated->process($data, $operation, $uriVariables, $context);
×
58
        }
59

60
        // return the Resource representation of the persisted entity
UNCOV
61
        return $this->objectMapper->map(
×
62
            // persist the entity
NEW
63
            $this->decorated->process(
×
64
                // maps the Resource to an Entity
NEW
65
                $this->objectMapper->map($data),
×
NEW
66
                $operation,
×
NEW
67
                $uriVariables,
×
NEW
68
                $context,
×
NEW
69
            ),
×
NEW
70
            $operation->getClass()
×
NEW
71
        );
×
72
    }
73
}
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

© 2026 Coveralls, Inc