src/Entity/ReportedPort.php line 46

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity;
  4. use ApiPlatform\Core\Annotation\ApiProperty;
  5. use ApiPlatform\Core\Annotation\ApiResource;
  6. use App\Trait\TimestampableEntity;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Symfony\Component\Serializer\Annotation\Groups;
  9. use Symfony\Component\Validator\Constraints as Assert;
  10. use Symfony\Component\Serializer\Annotation\MaxDepth;
  11. use Ramsey\Uuid\Uuid;
  12. use Ramsey\Uuid\UuidInterface;
  13. /**
  14.  * @see https://schema.org/Thing
  15.  *
  16.  * @author Jordi Fernandes Alves <jfadev@gmail.com>
  17.  */
  18. #[ORM\Entity]
  19. #[ApiResource(
  20.     iri'ReportedPort',
  21.     itemOperations: [
  22.         'get' => ['normalization_context' => ['groups' => 'reported_port:item:get''enable_max_depth' => true]],
  23.         'put' => [
  24.             'normalization_context' => ['groups' => 'reported_port:item:put''enable_max_depth' => true],
  25.             'denormalization_context' => ['groups' => 'reported_port:item:put''enable_max_depth' => true],
  26.         ],
  27.         'delete' => [],
  28.     ],
  29.     collectionOperations: [
  30.         'get' => [
  31.             'normalization_context' => [
  32.                 'groups' => ['reported_port:collection:get''createdAt'],
  33.                 'enable_max_depth' => true,
  34.             ],
  35.         ],
  36.         'post' => [
  37.             'normalization_context' => ['groups' => 'reported_port:collection:post''enable_max_depth' => true],
  38.             'denormalization_context' => ['groups' => 'reported_port:collection:post''enable_max_depth' => true],
  39.         ],
  40.     ],
  41. )]
  42. class ReportedPort
  43. {
  44.     use TimestampableEntity;
  45.     
  46.     #[ORM\Id]
  47.     #[ORM\GeneratedValue(strategy'NONE')]
  48.     #[ORM\Column(type'uuid'uniquetrue)]
  49.     private ?UuidInterface $id null;
  50.     #[ORM\ManyToOne(targetEntity'App\Entity\Port'inversedBy'reportedPorts')]
  51.     #[ORM\JoinColumn(nullabletrue)]
  52.     #[ApiProperty(iri'https://schema.org/port')]
  53.     #[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'])]
  54.     #[MaxDepth(1)]
  55.     private ?Port $port null;
  56.     #[ORM\ManyToOne(targetEntity'App\Entity\Contract'inversedBy'reportedPorts')]
  57.     #[ORM\JoinColumn(nullabletrue)]
  58.     #[ApiProperty(iri'https://schema.org/Contract')]
  59.     #[Groups(['reported_port:collection:get''reported_port:collection:post''reported_port:item:get''reported_port:item:put'])]
  60.     #[MaxDepth(1)]
  61.     private ?Contract $contract null;
  62.     public function __construct()
  63.     {
  64.         $this->id Uuid::uuid4();
  65.     }
  66.     public function getId(): ?UuidInterface
  67.     {
  68.         return $this->id;
  69.     }
  70.     public function setPort(?Port $port): void
  71.     {
  72.         $this->port $port;
  73.     }
  74.     public function getPort(): ?Port
  75.     {
  76.         return $this->port;
  77.     }
  78.     public function setContract(?Contract $contract): void
  79.     {
  80.         $this->contract $contract;
  81.     }
  82.     public function getContract(): ?Contract
  83.     {
  84.         return $this->contract;
  85.     }
  86. }