-
-
Notifications
You must be signed in to change notification settings - Fork 964
Expand file tree
/
Copy pathOrmFooResource.php
More file actions
53 lines (45 loc) · 1.3 KB
/
OrmFooResource.php
File metadata and controls
53 lines (45 loc) · 1.3 KB
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
<?php
/*
* This file is part of the API Platform project.
*
* (c) Kévin Dunglas <dunglas@gmail.com>
*
* 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\Issue6590;
use ApiPlatform\Doctrine\Orm\State\Options;
use ApiPlatform\Metadata\ApiProperty;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\GraphQl\Query;
use ApiPlatform\Metadata\GraphQl\QueryCollection;
use ApiPlatform\Tests\Fixtures\TestBundle\Entity\Issue6590\Foo;
use ApiPlatform\Tests\Fixtures\TestBundle\State\Issue6590\FooResourceProvider;
#[ApiResource(
shortName: 'Issue6590OrmFoo',
operations: [],
graphQlOperations: [
new Query(),
new QueryCollection(),
],
provider: FooResourceProvider::class,
stateOptions: new Options(entityClass: Foo::class)
)]
class OrmFooResource
{
#[ApiProperty(identifier: true)]
public int $id;
/**
* @var OrmBarResource[]
*/
public array $bars;
public function addBar(OrmBarResource $bar): void
{
$this->bars[] = $bar;
}
public function removeBar(OrmBarResource $bar): void
{
unset($this->bars[array_search($bar, $this->bars, true)]);
}
}