- nelmio/api-doc-bundle 4.x to 5.6 - phpstan/phpdoc-parser 1.x to 2.x - Fixed deprecations.
66 lines
1.7 KiB
PHP
66 lines
1.7 KiB
PHP
<?php
|
|
|
|
namespace App\Controller;
|
|
|
|
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
|
|
use App\Repository\RoomCategoryRepository;
|
|
use App\Entity\RoomCategory;
|
|
use Nelmio\ApiDocBundle\Attribute\Model;
|
|
use Symfony\Component\HttpFoundation\Response;
|
|
use Symfony\Component\Routing\Attribute\Route;
|
|
use OpenApi\Attributes as OA;
|
|
|
|
class RoomCategoryController extends AbstractController
|
|
{
|
|
|
|
/**
|
|
* Get All room categories.
|
|
*/
|
|
#[Route('/api/room/category', name: 'app_room_AllCategories', methods: ["GET"])]
|
|
#[OA\Tag(name: "Rooms")]
|
|
#[OA\Response(
|
|
response: 200,
|
|
description: 'Returns all room categories',
|
|
content: new OA\JsonContent(
|
|
type: 'object',
|
|
properties: [
|
|
new OA\Property(
|
|
property: "results",
|
|
type: "array",
|
|
items: new OA\Items(ref: new Model(type: RoomCategory::class))
|
|
)
|
|
]
|
|
)
|
|
)]
|
|
public function getAll(RoomCategoryRepository $catRepo): Response
|
|
{
|
|
$catList = $catRepo->findAll();
|
|
|
|
return $this->json(["results" => $catList]);
|
|
}
|
|
|
|
/**
|
|
* Get a room category by ID.
|
|
*/
|
|
#[Route('/api/room/category/{id}', name: 'app_room_category', methods: ["GET"])]
|
|
#[OA\Tag(name: "Rooms")]
|
|
#[OA\Response(
|
|
response: 200,
|
|
description: 'Returns a room category',
|
|
content: new OA\JsonContent(
|
|
type: 'object',
|
|
ref: new Model(type: RoomCategory::class),
|
|
)
|
|
)]
|
|
#[OA\Parameter(
|
|
name: 'id',
|
|
in: 'path',
|
|
description: 'RoomCategory ID',
|
|
)]
|
|
public function getById(RoomCategory $category): Response
|
|
{
|
|
return $this->json($category);
|
|
}
|
|
|
|
}
|