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

api-platform / core / 10903050455

17 Sep 2024 12:29PM UTC coverage: 7.684% (+0.7%) from 6.96%
10903050455

push

github

web-flow
fix: swagger ui with route identifier (#6616)

2 of 6 new or added lines in 6 files covered. (33.33%)

9000 existing lines in 286 files now uncovered.

12668 of 164863 relevant lines covered (7.68%)

22.93 hits per line

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

84.62
/src/Serializer/SerializerFilterContextBuilder.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\Serializer;
15

16
use ApiPlatform\Metadata\Exception\RuntimeException;
17
use ApiPlatform\Metadata\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
18
use ApiPlatform\Metadata\Util\AttributesExtractor;
19
use ApiPlatform\Serializer\Filter\FilterInterface;
20
use Psr\Container\ContainerInterface;
21
use Symfony\Component\HttpFoundation\Request;
22

23
/**
24
 * {@inheritdoc}
25
 *
26
 * @author Baptiste Meyer <baptiste.meyer@gmail.com>
27
 */
28
final class SerializerFilterContextBuilder implements SerializerContextBuilderInterface
29
{
30
    public function __construct(private readonly ResourceMetadataCollectionFactoryInterface $resourceMetadataCollectionFactory, private readonly ContainerInterface $filterLocator, private readonly SerializerContextBuilderInterface $decorated)
31
    {
UNCOV
32
    }
1,854✔
33

34
    /**
35
     * {@inheritdoc}
36
     */
37
    public function createFromRequest(Request $request, bool $normalization, ?array $attributes = null): array
38
    {
UNCOV
39
        if (null === $attributes && !$attributes = AttributesExtractor::extractAttributes($request->attributes->all())) {
1,845✔
40
            throw new RuntimeException('Request attributes are not valid.');
×
41
        }
42

UNCOV
43
        $context = $this->decorated->createFromRequest($request, $normalization, $attributes);
1,845✔
44

UNCOV
45
        if (!($operation = $context['operation'] ?? null)) {
1,845✔
46
            $operation = $this->resourceMetadataCollectionFactory->create($attributes['resource_class'])->getOperation($attributes['operation_name'] ?? null);
×
47
        }
48

UNCOV
49
        $resourceFilters = $operation->getFilters();
1,845✔
50

UNCOV
51
        if (!$resourceFilters) {
1,845✔
UNCOV
52
            return $context;
1,150✔
53
        }
54

UNCOV
55
        foreach ($resourceFilters as $filterId) {
771✔
UNCOV
56
            if ($this->filterLocator->has($filterId) && ($filter = $this->filterLocator->get($filterId)) instanceof FilterInterface) {
771✔
UNCOV
57
                $filter->apply($request, $normalization, $attributes, $context);
586✔
58
            }
59
        }
60

UNCOV
61
        return $context;
771✔
62
    }
63
}
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