<?php
declare(strict_types=1);
namespace App\Entity;
use ApiPlatform\Core\Annotation\ApiProperty;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Trait\TimestampableEntity;
use Doctrine\ORM\Mapping as ORM;
use Symfony\Component\Serializer\Annotation\Groups;
use Symfony\Component\Validator\Constraints as Assert;
use Symfony\Component\Serializer\Annotation\MaxDepth;
use Ramsey\Uuid\Uuid;
use Ramsey\Uuid\UuidInterface;
/**
* @see https://schema.org/Thing
*
* @author Jordi Fernandes Alves <jfadev@gmail.com>
*/
#[ORM\Entity]
#[ApiResource(
iri: 'ReportedPort',
itemOperations: [
'get' => ['normalization_context' => ['groups' => 'reported_port:item:get', 'enable_max_depth' => true]],
'put' => [
'normalization_context' => ['groups' => 'reported_port:item:put', 'enable_max_depth' => true],
'denormalization_context' => ['groups' => 'reported_port:item:put', 'enable_max_depth' => true],
],
'delete' => [],
],
collectionOperations: [
'get' => [
'normalization_context' => [
'groups' => ['reported_port:collection:get', 'createdAt'],
'enable_max_depth' => true,
],
],
'post' => [
'normalization_context' => ['groups' => 'reported_port:collection:post', 'enable_max_depth' => true],
'denormalization_context' => ['groups' => 'reported_port:collection:post', 'enable_max_depth' => true],
],
],
)]
class ReportedPort
{
use TimestampableEntity;
#[ORM\Id]
#[ORM\GeneratedValue(strategy: 'NONE')]
#[ORM\Column(type: 'uuid', unique: true)]
private ?UuidInterface $id = null;
#[ORM\ManyToOne(targetEntity: 'App\Entity\Port', inversedBy: 'reportedPorts')]
#[ORM\JoinColumn(nullable: true)]
#[ApiProperty(iri: 'https://schema.org/port')]
#[Groups(['reported_port:collection:get', 'reported_port:collection:post', 'reported_port:item:get', 'reported_port:item:put', 'contract:collection:post', 'contract:item:get', 'contract:item:put'])]
#[MaxDepth(1)]
private ?Port $port = null;
#[ORM\ManyToOne(targetEntity: 'App\Entity\Contract', inversedBy: 'reportedPorts')]
#[ORM\JoinColumn(nullable: true)]
#[ApiProperty(iri: 'https://schema.org/Contract')]
#[Groups(['reported_port:collection:get', 'reported_port:collection:post', 'reported_port:item:get', 'reported_port:item:put'])]
#[MaxDepth(1)]
private ?Contract $contract = null;
public function __construct()
{
$this->id = Uuid::uuid4();
}
public function getId(): ?UuidInterface
{
return $this->id;
}
public function setPort(?Port $port): void
{
$this->port = $port;
}
public function getPort(): ?Port
{
return $this->port;
}
public function setContract(?Contract $contract): void
{
$this->contract = $contract;
}
public function getContract(): ?Contract
{
return $this->contract;
}
}