-
-
Notifications
You must be signed in to change notification settings - Fork 893
/
Copy pathTestIssue5926.php
56 lines (46 loc) · 1.33 KB
/
TestIssue5926.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
<?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\Entity\Issue5926;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\Operation;
#[ApiResource(
operations: [
new Get(
provider: [TestIssue5926::class, 'provide']
),
]
)]
class TestIssue5926
{
public function __construct(
private readonly string $id,
private readonly ?ContentItemCollection $content,
) {
}
public function getId(): string
{
return $this->id;
}
public function getContent(): ?ContentItemCollection
{
return $this->content;
}
public static function provide(Operation $operation, array $uriVariables = [], array $context = []): object|array|null
{
$media = new Media('1', 'My media');
$contentItem1 = new MediaContentItem($media);
$media = new Media('2', 'My media 2');
$contentItem2 = new MediaContentItem($media);
$collection = new ContentItemCollection($contentItem1, $contentItem2);
return new self('1', $collection);
}
}