-
-
Notifications
You must be signed in to change notification settings - Fork 878
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #6798 from soyuka/merge-34
- Loading branch information
Showing
15 changed files
with
349 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
64 changes: 64 additions & 0 deletions
64
tests/Fixtures/TestBundle/ApiResource/Issue4358/ResourceA.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\Issue4358; | ||
|
||
use ApiPlatform\Metadata\ApiProperty; | ||
use ApiPlatform\Metadata\Get; | ||
use Symfony\Component\Serializer\Annotation\Groups; | ||
use Symfony\Component\Serializer\Annotation\MaxDepth; | ||
|
||
#[Get(uriTemplate: 'resource_a', | ||
formats: ['jsonhal'], | ||
outputFormats: ['jsonhal'], | ||
normalizationContext: ['groups' => ['ResourceA:read'], 'enable_max_depth' => true], | ||
provider: [self::class, 'provide'])] | ||
final class ResourceA | ||
{ | ||
private static ?ResourceA $resourceA = null; | ||
|
||
#[ApiProperty(readableLink: true)] | ||
#[Groups(['ResourceA:read', 'ResourceB:read'])] | ||
#[MaxDepth(6)] | ||
public ResourceB $b; | ||
|
||
public function __construct(?ResourceB $b = null) | ||
{ | ||
if (null !== $b) { | ||
$this->b = $b; | ||
} | ||
} | ||
|
||
public static function provide(): self | ||
{ | ||
return self::provideWithResource(); | ||
} | ||
|
||
public static function provideWithResource(?ResourceB $b = null): self | ||
{ | ||
if (!isset(self::$resourceA)) { | ||
self::$resourceA = new self($b); | ||
|
||
if (null === ResourceB::getInstance()) { | ||
self::$resourceA->b = ResourceB::provideWithResource(self::$resourceA); | ||
} | ||
} | ||
|
||
return self::$resourceA; | ||
} | ||
|
||
public static function getInstance(): ?self | ||
{ | ||
return self::$resourceA; | ||
} | ||
} |
64 changes: 64 additions & 0 deletions
64
tests/Fixtures/TestBundle/ApiResource/Issue4358/ResourceB.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the API Platform project. | ||
* | ||
* (c) Kévin Dunglas <[email protected]> | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace ApiPlatform\Tests\Fixtures\TestBundle\ApiResource\Issue4358; | ||
|
||
use ApiPlatform\Metadata\ApiProperty; | ||
use ApiPlatform\Metadata\Get; | ||
use Symfony\Component\Serializer\Annotation\Groups; | ||
use Symfony\Component\Serializer\Annotation\MaxDepth; | ||
|
||
#[Get(uriTemplate: 'resource_b', | ||
formats: ['jsonhal'], | ||
outputFormats: ['jsonhal'], | ||
normalizationContext: ['groups' => ['ResourceB:read'], 'enable_max_depth' => true], | ||
provider: [self::class, 'provide'])] | ||
final class ResourceB | ||
{ | ||
private static ?ResourceB $resourceB = null; | ||
|
||
#[ApiProperty(readableLink: true)] | ||
#[Groups(['ResourceA:read', 'ResourceB:read'])] | ||
#[MaxDepth(6)] | ||
public ResourceA $a; | ||
|
||
public function __construct(?ResourceA $a = null) | ||
{ | ||
if (null !== $a) { | ||
$this->a = $a; | ||
} | ||
} | ||
|
||
public static function provide(): self | ||
{ | ||
return self::provideWithResource(); | ||
} | ||
|
||
public static function provideWithResource(?ResourceA $a = null): self | ||
{ | ||
if (!isset(self::$resourceB)) { | ||
self::$resourceB = new self($a); | ||
|
||
if (null === ResourceA::getInstance()) { | ||
self::$resourceB->a = ResourceA::provideWithResource(self::$resourceB); | ||
} | ||
} | ||
|
||
return self::$resourceB; | ||
} | ||
|
||
public static function getInstance(): ?self | ||
{ | ||
return self::$resourceB; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ | |
/** | ||
* Dummy Product. | ||
* | ||
* https://github.com/api-platform/core/issues/1107. | ||
* @see https://github.com/api-platform/core/issues/1107 | ||
* | ||
* @author Antoine Bluchet <[email protected]> | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -23,7 +23,7 @@ | |
/** | ||
* Dummy Product. | ||
* | ||
* https://github.com/api-platform/core/issues/1107. | ||
* @see https://github.com/api-platform/core/issues/1107 | ||
* | ||
* @author Antoine Bluchet <[email protected]> | ||
*/ | ||
|
Oops, something went wrong.