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

api-platform / core / 6067528200

04 Sep 2023 12:12AM UTC coverage: 36.875% (-21.9%) from 58.794%
6067528200

Pull #5791

github

web-flow
Merge 64157e578 into d09cfc9d2
Pull Request #5791: fix: strip down any sql function name

3096 of 3096 new or added lines in 205 files covered. (100.0%)

9926 of 26918 relevant lines covered (36.87%)

6.5 hits per line

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

90.0
/src/State/Processor/AddLinkHeaderProcessor.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\HttpFoundation\Response;
19
use Symfony\Component\WebLink\HttpHeaderSerializer;
20

21
final class AddLinkHeaderProcessor implements ProcessorInterface
22
{
23
    public function __construct(private readonly ProcessorInterface $decorated, private readonly ?HttpHeaderSerializer $serializer = new HttpHeaderSerializer())
24
    {
25
    }
58✔
26

27
    public function process(mixed $data, Operation $operation, array $uriVariables = [], array $context = []): mixed
28
    {
29
        $response = $this->decorated->process($data, $operation, $uriVariables, $context);
58✔
30

31
        if (
32
            !($request = $context['request'] ?? null)
58✔
33
            || !$response instanceof Response
58✔
34
        ) {
35
            return $response;
×
36
        }
37

38
        // We add our header here as Symfony does it only for the main Request and we want it to be done on errors (sub-request) as well
39
        $linksProvider = $request->attributes->get('_links');
58✔
40
        if ($this->serializer && ($links = $linksProvider->getLinks())) {
58✔
41
            $response->headers->set('Link', $this->serializer->serialize($links));
58✔
42
            // We don't want Symfony WebLink component do add links twice
43
            $request->attributes->set('_links', []);
58✔
44
        }
45

46
        return $response;
58✔
47
    }
48
}
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