Skip to content

Commit 2d2d616

Browse files
committed
Merge branch 2.7 into 3.0
2 parents 0ed8fbc + 176fff2 commit 2d2d616

File tree

12 files changed

+211
-12
lines changed

12 files changed

+211
-12
lines changed

src/Doctrine/Odm/Extension/OrderExtension.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use Doctrine\ODM\MongoDB\Aggregation\Builder;
2020
use Doctrine\ODM\MongoDB\Aggregation\Stage\Sort;
2121
use Doctrine\Persistence\ManagerRegistry;
22-
use OutOfRangeException;
2322

2423
/**
2524
* Applies selected ordering while querying resource collection.
@@ -100,7 +99,7 @@ private function hasSortStage(Builder $aggregationBuilder): bool
10099
// If at least one stage is sort, then it has sorting
101100
return true;
102101
}
103-
} catch (OutOfRangeException) {
102+
} catch (\OutOfRangeException $outOfRangeException) {
104103
// There is no more stages on the aggregation builder
105104
$shouldStop = true;
106105
}

src/Metadata/Operations.php

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,6 @@
1313

1414
namespace ApiPlatform\Metadata;
1515

16-
/**
17-
* @internal
18-
*/
1916
final class Operations implements \IteratorAggregate, \Countable
2017
{
2118
private array $operations = [];

src/Metadata/Resource/Factory/OperationDefaultsTrait.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -137,8 +137,8 @@ private function getOperationWithDefaults(ApiResource $resource, Operation $oper
137137
}
138138

139139
// Check for name conflict
140-
if ($operation->getName()) {
141-
if (null !== $resource->getOperations() && !$resource->getOperations()->has($operation->getName())) {
140+
if ($operation->getName() && null !== ($operations = $resource->getOperations())) {
141+
if (!$operations->has($operation->getName())) {
142142
return [$operation->getName(), $operation];
143143
}
144144

src/Symfony/Bundle/ArgumentResolver/PayloadArgumentResolver.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,6 @@ private function getExpectedInputClass(Request $request): ?string
7171

7272
$context = $this->serializationContextBuilder->createFromRequest($request, false, RequestAttributesExtractor::extractAttributes($request));
7373

74-
return $context['input'] ?? $context['resource_class'];
74+
return $context['input']['class'] ?? $context['resource_class'] ?? null;
7575
}
7676
}

tests/Fixtures/TestBundle/Document/VoDummyInspection.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,12 @@ class VoDummyInspection
2626
#[ODM\Field(type: 'date')]
2727
private \DateTime $performed;
2828

29-
public function __construct(#[Groups(['car_read', 'car_write', 'inspection_read', 'inspection_write'])] #[ODM\Field(type: 'bool')] private bool $accepted, #[Groups(['inspection_read', 'inspection_write'])] #[ODM\ReferenceOne(targetDocument: VoDummyCar::class, inversedBy: 'inspections')] private VoDummyCar $car, \DateTime $performed = null, private string $attributeWithoutConstructorEquivalent = '')
29+
private $attributeWithoutConstructorEquivalent;
30+
31+
public function __construct(#[Groups(['car_read', 'car_write', 'inspection_read', 'inspection_write'])] #[ODM\Field(type: 'bool')] private bool $accepted, #[Groups(['inspection_read', 'inspection_write'])] #[ODM\ReferenceOne(targetDocument: VoDummyCar::class, inversedBy: 'inspections')] private VoDummyCar $car, \DateTime $performed = null, string $parameterWhichIsNotClassAttribute = '')
3032
{
3133
$this->performed = $performed ?: new \DateTime();
34+
$this->attributeWithoutConstructorEquivalent = $parameterWhichIsNotClassAttribute;
3235
}
3336

3437
public function isAccepted(): bool
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the API Platform project.
5+
*
6+
* (c) Kévin Dunglas <[email protected]>
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\Tests\Fixtures\TestBundle\Entity;
15+
16+
use ApiPlatform\Metadata\Get;
17+
18+
#[Get(name: 'my own name')]
19+
final class AttributeOnlyOperation
20+
{
21+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the API Platform project.
5+
*
6+
* (c) Kévin Dunglas <[email protected]>
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\Tests\Fixtures\TestBundle\Entity;
15+
16+
use ApiPlatform\Core\Annotation\ApiResource;
17+
use Doctrine\Common\Collections\Collection;
18+
use Doctrine\ORM\Mapping as ORM;
19+
20+
/**
21+
* @ORM\Entity
22+
*
23+
* @ApiResource
24+
*/
25+
class DummyToUpgradeProduct
26+
{
27+
/**
28+
* @var int
29+
*
30+
* @ORM\Id
31+
* @ORM\GeneratedValue
32+
* @ORM\Column(type="integer")
33+
*/
34+
private $id;
35+
36+
/**
37+
* @var Collection<int,DummyToUpgradeWithOnlyAnnotation>
38+
*
39+
* @ORM\OneToMany(mappedBy="dummyToUpgradeProduct", targetEntity=DummyToUpgradeWithOnlyAnnotation::class)
40+
*/
41+
private $dummysToUpgradeWithOnlyAnnotation;
42+
43+
/**
44+
* @var Collection<int,DummyToUpgradeWithOnlyAttribute>
45+
*
46+
* @ORM\OneToMany(mappedBy="dummyToUpgradeProduct", targetEntity=DummyToUpgradeWithOnlyAttribute::class)
47+
*/
48+
private $dummysToUpgradeWithOnlyAttribute;
49+
}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the API Platform project.
5+
*
6+
* (c) Kévin Dunglas <[email protected]>
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\Tests\Fixtures\TestBundle\Entity;
15+
16+
use ApiPlatform\Core\Annotation\ApiFilter;
17+
use ApiPlatform\Core\Annotation\ApiProperty;
18+
use ApiPlatform\Core\Annotation\ApiResource;
19+
use ApiPlatform\Core\Annotation\ApiSubresource;
20+
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\DateFilter;
21+
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\ExistsFilter;
22+
use ApiPlatform\Core\Bridge\Doctrine\Orm\Filter\SearchFilter;
23+
use Doctrine\ORM\Mapping as ORM;
24+
use Symfony\Component\Serializer\Annotation\Groups;
25+
26+
/**
27+
* @ORM\Entity
28+
*
29+
* @ApiResource
30+
*
31+
* @ApiFilter(SearchFilter::class, properties={"id"})
32+
*/
33+
class DummyToUpgradeWithOnlyAnnotation
34+
{
35+
/**
36+
* @var int
37+
*
38+
* @ORM\Id
39+
* @ORM\GeneratedValue
40+
* @ORM\Column(type="integer")
41+
* @Groups({"chicago", "friends"})
42+
* @ApiProperty(writable=false)
43+
* @ApiFilter(DateFilter::class)
44+
*/
45+
private $id;
46+
47+
/**
48+
* @var DummyToUpgradeProduct
49+
*
50+
* @ORM\ManyToOne(targetEntity="DummyToUpgradeProduct", cascade={"persist"}, inversedBy="dummysToUpgradeWithOnlyAnnotation")
51+
* @ORM\JoinColumn(nullable=false)
52+
* @Groups({"barcelona", "chicago", "friends"})
53+
*
54+
* @ApiSubresource
55+
*
56+
* @ApiProperty(iri="DummyToUpgradeWithOnlyAnnotation.dummyToUpgradeProduct")
57+
* @ApiFilter(SearchFilter::class)
58+
* @ApiFilter(ExistsFilter::class)
59+
*/
60+
private $dummyToUpgradeProduct;
61+
}
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
<?php
2+
3+
/*
4+
* This file is part of the API Platform project.
5+
*
6+
* (c) Kévin Dunglas <[email protected]>
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\Tests\Fixtures\TestBundle\Entity;
15+
16+
use ApiPlatform\Core\Annotation\ApiProperty;
17+
use ApiPlatform\Core\Annotation\ApiResource;
18+
use ApiPlatform\Core\Annotation\ApiSubresource;
19+
use Doctrine\ORM\Mapping as ORM;
20+
use Symfony\Component\Serializer\Annotation\Groups;
21+
22+
/**
23+
* @ORM\Entity
24+
*/
25+
#[ApiResource()]
26+
class DummyToUpgradeWithOnlyAttribute
27+
{
28+
/**
29+
* @var int
30+
*
31+
* @ORM\Id
32+
* @ORM\GeneratedValue
33+
* @ORM\Column(type="integer")
34+
*/
35+
#[Groups(['chicago', 'friends'])]
36+
#[ApiProperty(writable: false)]
37+
private $id;
38+
39+
/**
40+
* @var DummyToUpgradeProduct
41+
*
42+
* @ORM\ManyToOne(targetEntity="DummyToUpgradeProduct", inversedBy="dummysToUpgradeWithOnlyAttribute")
43+
* @ORM\JoinColumn(nullable=false)
44+
*/
45+
#[Groups(['barcelona', 'chicago', 'friends'])]
46+
#[ApiSubresource]
47+
#[ApiProperty(iri: 'DummyToUpgradeWithOnlyAttribute.dummyToUpgradeProduct')]
48+
private $dummyToUpgradeProduct;
49+
}

tests/Fixtures/TestBundle/Entity/VoDummyInspection.php

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,12 @@ class VoDummyInspection
2727
#[Groups(['car_read', 'car_write', 'inspection_read', 'inspection_write'])]
2828
private \DateTime $performed;
2929

30-
public function __construct(#[ORM\Column(type: 'boolean')] #[Groups(['car_read', 'car_write', 'inspection_read', 'inspection_write'])] private bool $accepted, #[ORM\ManyToOne(targetEntity: VoDummyCar::class, inversedBy: 'inspections')] #[Groups(['inspection_read', 'inspection_write'])] private ?VoDummyCar $car, \DateTime $performed = null, private string $attributeWithoutConstructorEquivalent = '')
30+
private $attributeWithoutConstructorEquivalent;
31+
32+
public function __construct(#[ORM\Column(type: 'boolean')] #[Groups(['car_read', 'car_write', 'inspection_read', 'inspection_write'])] private bool $accepted, #[ORM\ManyToOne(targetEntity: VoDummyCar::class, inversedBy: 'inspections')] #[Groups(['inspection_read', 'inspection_write'])] private ?VoDummyCar $car, \DateTime $performed = null, string $parameterWhichIsNotClassAttribute = '')
3133
{
3234
$this->performed = $performed ?: new \DateTime();
35+
$this->attributeWithoutConstructorEquivalent = $parameterWhichIsNotClassAttribute;
3336
}
3437

3538
public function isAccepted(): bool

0 commit comments

Comments
 (0)