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

api-platform / core / 7355537923

29 Dec 2023 09:42AM UTC coverage: 37.321% (-0.009%) from 37.33%
7355537923

push

github

web-flow
GraphQL: Nested Collections (#6038)

* feat(graphql): support nested collections

* null safe operator

---------

Co-authored-by: josef.wagner <josef.wagner@hf-solutions.co>
Co-authored-by: Antoine Bluchet <soyuka@users.noreply.github.com>

11 of 29 new or added lines in 4 files covered. (37.93%)

71 existing lines in 9 files now uncovered.

10360 of 27759 relevant lines covered (37.32%)

28.59 hits per line

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

84.62
/src/Symfony/EventListener/ValidateListener.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\Resource\Factory\ResourceMetadataCollectionFactoryInterface;
17
use ApiPlatform\State\Util\OperationRequestInitiatorTrait;
18
use ApiPlatform\Validator\Exception\ValidationException;
19
use ApiPlatform\Validator\ValidatorInterface;
20
use Symfony\Component\HttpFoundation\Response;
21
use Symfony\Component\HttpKernel\Event\ViewEvent;
22

23
/**
24
 * Validates data.
25
 *
26
 * @author Kévin Dunglas <dunglas@gmail.com>
27
 */
28
final class ValidateListener
29
{
30
    use OperationRequestInitiatorTrait;
31

32
    public const OPERATION_ATTRIBUTE_KEY = 'validate';
33

34
    public function __construct(private readonly ValidatorInterface $validator, ResourceMetadataCollectionFactoryInterface $resourceMetadataCollectionFactory)
35
    {
UNCOV
36
        $this->resourceMetadataCollectionFactory = $resourceMetadataCollectionFactory;
14✔
37
    }
38

39
    /**
40
     * Validates data returned by the controller if applicable.
41
     *
42
     * @throws ValidationException
43
     */
44
    public function onKernelView(ViewEvent $event): void
45
    {
UNCOV
46
        $controllerResult = $event->getControllerResult();
14✔
UNCOV
47
        $request = $event->getRequest();
14✔
UNCOV
48
        $operation = $this->initializeOperation($request);
14✔
UNCOV
49
        if ('api_platform.symfony.main_controller' === $operation?->getController() || $request->attributes->get('_api_platform_disable_listeners')) {
14✔
50
            return;
×
51
        }
52

53
        if (
UNCOV
54
            $controllerResult instanceof Response
14✔
UNCOV
55
            || $request->isMethodSafe()
14✔
UNCOV
56
            || $request->isMethod('DELETE')
14✔
57
        ) {
UNCOV
58
            return;
11✔
59
        }
60

UNCOV
61
        if (!$operation || !($operation->canValidate() ?? true)) {
3✔
62
            return;
×
63
        }
64

UNCOV
65
        $this->validator->validate($controllerResult, $operation->getValidationContext() ?? []);
3✔
66
    }
67
}
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