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

api-platform / core / 20720667524

05 Jan 2026 03:44PM UTC coverage: 25.305%. Remained the same
20720667524

Pull #7638

github

web-flow
chore(deps): bump actions/cache from 4 to 5

Bumps [actions/cache](https://github.com/actions/cache) from 4 to 5.
- [Release notes](https://github.com/actions/cache/releases)
- [Changelog](https://github.com/actions/cache/blob/main/RELEASES.md)
- [Commits](https://github.com/actions/cache/compare/v4...v5)

---
updated-dependencies:
- dependency-name: actions/cache
  dependency-version: '5'
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Pull Request #7638: chore(deps): bump actions/cache from 4 to 5

14741 of 58254 relevant lines covered (25.3%)

30.23 hits per line

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

87.5
/src/Symfony/EventListener/WriteListener.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\Symfony\EventListener;
15

16
use ApiPlatform\Metadata\Error;
17
use ApiPlatform\Metadata\Exception\InvalidIdentifierException;
18
use ApiPlatform\Metadata\Exception\InvalidUriVariableException;
19
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
20
use ApiPlatform\Metadata\UriVariablesConverterInterface;
21
use ApiPlatform\Metadata\Util\ClassInfoTrait;
22
use ApiPlatform\Metadata\Util\CloneTrait;
23
use ApiPlatform\State\ProcessorInterface;
24
use ApiPlatform\State\UriVariablesResolverTrait;
25
use ApiPlatform\State\Util\OperationRequestInitiatorTrait;
26
use ApiPlatform\State\Util\RequestAttributesExtractor;
27
use Symfony\Component\HttpKernel\Event\ViewEvent;
28
use Symfony\Component\HttpKernel\Exception\NotFoundHttpException;
29

30
/**
31
 * Bridges persistence and the API system.
32
 *
33
 * @author Kévin Dunglas <dunglas@gmail.com>
34
 * @author Baptiste Meyer <baptiste.meyer@gmail.com>
35
 */
36
final class WriteListener
37
{
38
    use ClassInfoTrait;
39
    use CloneTrait;
40
    use OperationRequestInitiatorTrait;
41
    use UriVariablesResolverTrait;
42

43
    /**
44
     * @param ProcessorInterface<mixed, mixed> $processor
45
     */
46
    public function __construct(
47
        private readonly ProcessorInterface $processor,
48
        ?ResourceMetadataCollectionFactoryInterface $resourceMetadataCollectionFactory = null,
49
        ?UriVariablesConverterInterface $uriVariablesConverter = null,
50
    ) {
51
        $this->uriVariablesConverter = $uriVariablesConverter;
306✔
52
        $this->resourceMetadataCollectionFactory = $resourceMetadataCollectionFactory;
306✔
53
    }
54

55
    /**
56
     * Persists, updates or delete data return by the controller if applicable.
57
     */
58
    public function onKernelView(ViewEvent $event): void
59
    {
60
        $request = $event->getRequest();
306✔
61
        $operation = $this->initializeOperation($request);
306✔
62

63
        if (!($attributes = RequestAttributesExtractor::extractAttributes($request)) || !$attributes['persist'] || !$operation) {
306✔
64
            return;
×
65
        }
66

67
        if (null === $operation->canWrite()) {
306✔
68
            $operation = $operation->withWrite(!$request->isMethodSafe());
304✔
69
        }
70

71
        $uriVariables = $request->attributes->get('_api_uri_variables') ?? [];
306✔
72
        if (!$uriVariables && !$operation instanceof Error) {
306✔
73
            try {
74
                $uriVariables = $this->getOperationUriVariables($operation, $request->attributes->all(), $operation->getClass());
190✔
75
            } catch (InvalidIdentifierException|InvalidUriVariableException $e) {
×
76
                throw new NotFoundHttpException('Invalid identifier value or configuration.', $e);
×
77
            }
78
        }
79

80
        $data = $this->processor->process($event->getControllerResult(), $operation, $uriVariables, [
306✔
81
            'request' => $request,
306✔
82
            'uri_variables' => $uriVariables,
306✔
83
            'resource_class' => $operation->getClass(),
306✔
84
            'previous_data' => false === $operation->canRead() ? null : $request->attributes->get('previous_data'), // this is a clone
306✔
85
            'read_data' => false === $operation->canRead() ? null : $request->attributes->get('read_data'), // this is what we read
306✔
86
            'data' => false === $operation->canRead() ? null : $request->attributes->get('data'), // this should be the same as getControllerResult but is the result of deserialization
306✔
87
        ]);
306✔
88

89
        if ($data) {
306✔
90
            $request->attributes->set('original_data', $data);
306✔
91
        }
92

93
        $event->setControllerResult($data);
306✔
94
    }
95
}
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