Skip to content

Commit 010cdf0

Browse files
author
Benjamin RICHARD
committed
fix partially #117
1 parent 8254b55 commit 010cdf0

File tree

2 files changed

+34
-2
lines changed

2 files changed

+34
-2
lines changed

src/DataProvider/PingDataProvider.php

+6-2
Original file line numberDiff line numberDiff line change
@@ -17,15 +17,19 @@ public function supports(string $resourceClass, string $operationName = null, ar
1717
public function getItem(string $resourceClass, $id, string $operationName = null, array $context = [])
1818
{
1919
$pong = new Ping();
20+
$pong->setId(1);
2021

2122
return $pong;
2223
}
2324

2425
public function getCollection(string $resourceClass, string $operationName = null, array $context = [])
2526
{
26-
$pong = new Ping();
27+
$pongOne = new Ping();
28+
$pongOne->setId(1);
29+
$pongTwo = new Ping();
30+
$pongTwo->setId(2);
2731

28-
return [$pong];
32+
return [$pongOne, $pongTwo];
2933
}
3034

3135
}

src/Entity/Ping.php

+28
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
<?php
22
namespace App\Entity;
33

4+
use ApiPlatform\Core\Annotation\ApiProperty;
45
use ApiPlatform\Core\Annotation\ApiResource;
6+
use Symfony\Component\Validator\Constraints as Assert;
57

68
/**
79
* Class Ping
@@ -17,11 +19,37 @@
1719
*/
1820
class Ping
1921
{
22+
/**
23+
* @Assert\Uuid()
24+
* @ApiProperty(identifier=true)
25+
* @var int
26+
*/
27+
protected $id;
28+
2029
/**
2130
* @var string
2231
*/
2332
protected $pong = 'pong';
2433

34+
/**
35+
* @return int
36+
*/
37+
public function getId(): int
38+
{
39+
return $this->id;
40+
}
41+
42+
/**
43+
* @param int $id
44+
* @return Ping
45+
*/
46+
public function setId(int $id): Ping
47+
{
48+
$this->id = $id;
49+
50+
return $this;
51+
}
52+
2553
/**
2654
* @return string
2755
*/

0 commit comments

Comments
 (0)