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

api-platform / core / 3712739783

pending completion
3712739783

Pull #5254

github

GitHub
Merge 9dfa88fa6 into ac711530f
Pull Request #5254: [OpenApi] Add ApiResource::openapi and deprecate openapiContext

199 of 199 new or added lines in 6 files covered. (100.0%)

7494 of 12363 relevant lines covered (60.62%)

67.55 hits per line

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

0.0
/src/Doctrine/Orm/PropertyHelperTrait.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\Doctrine\Orm;
15

16
use ApiPlatform\Doctrine\Orm\Util\QueryBuilderHelper;
17
use ApiPlatform\Doctrine\Orm\Util\QueryNameGeneratorInterface;
18
use ApiPlatform\Exception\InvalidArgumentException;
19
use Doctrine\ORM\QueryBuilder;
20

21
/**
22
 * Helper trait regarding a property in an entity using the resource metadata.
23
 *
24
 * @author Kévin Dunglas <dunglas@gmail.com>
25
 * @author Théo FIDRY <theo.fidry@gmail.com>
26
 */
27
trait PropertyHelperTrait
28
{
29
    /**
30
     * Splits the given property into parts.
31
     */
32
    abstract protected function splitPropertyParts(string $property, string $resourceClass): array;
33

34
    /**
35
     * Adds the necessary joins for a nested property.
36
     *
37
     * @throws InvalidArgumentException If property is not nested
38
     *
39
     * @return array An array where the first element is the join $alias of the leaf entity,
40
     *               the second element is the $field name
41
     *               the third element is the $associations array
42
     */
43
    protected function addJoinsForNestedProperty(string $property, string $rootAlias, QueryBuilder $queryBuilder, QueryNameGeneratorInterface $queryNameGenerator, string $resourceClass, string $joinType): array
44
    {
45
        $propertyParts = $this->splitPropertyParts($property, $resourceClass);
×
46
        $parentAlias = $rootAlias;
×
47
        $alias = null;
×
48

49
        foreach ($propertyParts['associations'] as $association) {
×
50
            $alias = QueryBuilderHelper::addJoinOnce($queryBuilder, $queryNameGenerator, $parentAlias, $association, $joinType);
×
51
            $parentAlias = $alias;
×
52
        }
53

54
        if (null === $alias) {
×
55
            throw new InvalidArgumentException(sprintf('Cannot add joins for property "%s" - property is not nested.', $property));
×
56
        }
57

58
        return [$alias, $propertyParts['field'], $propertyParts['associations']];
×
59
    }
60
}
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