Skip to content

Commit

Permalink
use property attributes
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskapp committed Aug 21, 2024
1 parent e054df6 commit f03a5ce
Showing 1 changed file with 8 additions and 11 deletions.
19 changes: 8 additions & 11 deletions src/Controller/Population.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,14 @@
use App\Model;
use App\Service;
use App\Table;
use PSX\Api\Attribute\Body;
use PSX\Api\Attribute\Delete;
use PSX\Api\Attribute\Get;
use PSX\Api\Attribute\Param;
use PSX\Api\Attribute\Path;
use PSX\Api\Attribute\Post;
use PSX\Api\Attribute\Put;
use PSX\Api\Attribute\Tags;
use PSX\Api\Attribute\Query;
use PSX\Framework\Controller\ControllerAbstract;

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

#[Get]
#[Path('/population')]
#[Tags(['population'])]
public function getAll(?int $startIndex = null, ?int $count = null): Model\PopulationCollection
public function getAll(#[Query] ?int $startIndex = null, #[Query] ?int $count = null): Model\PopulationCollection
{
return $this->populationTable->getCollection($startIndex, $count);
}

#[Get]
#[Path('/population/:id')]
#[Tags(['population'])]
public function get(int $id): Model\Population
public function get(#[Param] int $id): Model\Population
{
return $this->populationTable->getEntity($id);
}

#[Post]
#[Path('/population')]
#[Tags(['population'])]
public function create(Model\Population $payload): Model\Message
public function create(#[Body] Model\Population $payload): Model\Message
{
$id = $this->populationService->create($payload);

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

#[Put]
#[Path('/population/:id')]
#[Tags(['population'])]
public function update(int $id, Model\Population $payload): Model\Message
public function update(#[Param] int $id, #[Body] Model\Population $payload): Model\Message
{
$id = $this->populationService->update($id, $payload);

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

#[Delete]
#[Path('/population/:id')]
#[Tags(['population'])]
public function delete(int $id): Model\Message
public function delete(#[Param] int $id): Model\Message
{
$id = $this->populationService->delete($id);

Expand Down

0 comments on commit f03a5ce

Please sign in to comment.