Skip to content

Commit f03a5ce

Browse files
committed
use property attributes
1 parent e054df6 commit f03a5ce

File tree

1 file changed

+8
-11
lines changed

1 file changed

+8
-11
lines changed

src/Controller/Population.php

+8-11
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,14 @@
55
use App\Model;
66
use App\Service;
77
use App\Table;
8+
use PSX\Api\Attribute\Body;
89
use PSX\Api\Attribute\Delete;
910
use PSX\Api\Attribute\Get;
11+
use PSX\Api\Attribute\Param;
1012
use PSX\Api\Attribute\Path;
1113
use PSX\Api\Attribute\Post;
1214
use PSX\Api\Attribute\Put;
13-
use PSX\Api\Attribute\Tags;
15+
use PSX\Api\Attribute\Query;
1416
use PSX\Framework\Controller\ControllerAbstract;
1517

1618
class Population extends ControllerAbstract
@@ -26,24 +28,21 @@ public function __construct(Service\Population $populationService, Table\Populat
2628

2729
#[Get]
2830
#[Path('/population')]
29-
#[Tags(['population'])]
30-
public function getAll(?int $startIndex = null, ?int $count = null): Model\PopulationCollection
31+
public function getAll(#[Query] ?int $startIndex = null, #[Query] ?int $count = null): Model\PopulationCollection
3132
{
3233
return $this->populationTable->getCollection($startIndex, $count);
3334
}
3435

3536
#[Get]
3637
#[Path('/population/:id')]
37-
#[Tags(['population'])]
38-
public function get(int $id): Model\Population
38+
public function get(#[Param] int $id): Model\Population
3939
{
4040
return $this->populationTable->getEntity($id);
4141
}
4242

4343
#[Post]
4444
#[Path('/population')]
45-
#[Tags(['population'])]
46-
public function create(Model\Population $payload): Model\Message
45+
public function create(#[Body] Model\Population $payload): Model\Message
4746
{
4847
$id = $this->populationService->create($payload);
4948

@@ -56,8 +55,7 @@ public function create(Model\Population $payload): Model\Message
5655

5756
#[Put]
5857
#[Path('/population/:id')]
59-
#[Tags(['population'])]
60-
public function update(int $id, Model\Population $payload): Model\Message
58+
public function update(#[Param] int $id, #[Body] Model\Population $payload): Model\Message
6159
{
6260
$id = $this->populationService->update($id, $payload);
6361

@@ -70,8 +68,7 @@ public function update(int $id, Model\Population $payload): Model\Message
7068

7169
#[Delete]
7270
#[Path('/population/:id')]
73-
#[Tags(['population'])]
74-
public function delete(int $id): Model\Message
71+
public function delete(#[Param] int $id): Model\Message
7572
{
7673
$id = $this->populationService->delete($id);
7774

0 commit comments

Comments
 (0)