webarchi/src/Entity/Building.php

61 lines
1.3 KiB
PHP

<?php
namespace App\Entity;
use ApiPlatform\Metadata\ApiResource;
use ApiPlatform\Metadata\Get;
use ApiPlatform\Metadata\Post;
use ApiPlatform\Metadata\GetCollection;
use App\Repository\BuildingRepository;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Attribute\Groups;
#[ORM\Entity(repositoryClass: BuildingRepository::class)]
#[ORM\Table(name: 'architettura')]
#[ApiResource(
operations: [
new Get(normalizationContext: ['groups' => 'building:item']),
new GetCollection(normalizationContext: ['groups' => 'building:list']),
// TODO Security!!
new Post(),
],
order: ['name' => 'DESC'],
paginationEnabled: false,
)]
class Building
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
#[Groups(['building:list', 'building:item'])]
private ?int $id = null;
#[ORM\Column(length: 255, name: 'denominazione')]
#[Groups(['building:list', 'building:item'])]
private ?string $name = null;
public function getId(): ?int
{
return $this->id;
}
public function setId(int $id): static
{
$this->id = $id;
return $this;
}
public function getName(): ?string
{
return $this->name;
}
public function setName(string $name): static
{
$this->name = $name;
return $this;
}
}