src/Point/Doctrine/Entity/TransferType.php line 29

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Point\Doctrine\Entity;
  4. use ApiPlatform\Core\Annotation\ApiProperty;
  5. use ApiPlatform\Core\Annotation\ApiResource;
  6. use App\Point\Doctrine\Repository\TransferTypeRepository;
  7. use Doctrine\Common\Collections\Collection;
  8. use Doctrine\ORM\Mapping\Column;
  9. use Doctrine\ORM\Mapping\Entity;
  10. use Doctrine\ORM\Mapping\GeneratedValue;
  11. use Doctrine\ORM\Mapping\Id;
  12. use Doctrine\ORM\Mapping\OneToMany;
  13. use Doctrine\ORM\Mapping\Table;
  14. use Symfony\Component\Serializer\Annotation\Groups;
  15. use Symfony\Component\Validator\Constraints\NotBlank;
  16. #[ApiResource(
  17.     collectionOperations: ['get''post'],
  18. //    itemOperations: ['get' => ['security' => 'is_granted("item", object)']],
  19.     itemOperations: ['get'],
  20.     normalizationContext: ['groups' => ['read']],
  21.     denormalizationContext: ['groups' => ['write']]
  22. )]
  23. #[Entity(repositoryClassTransferTypeRepository::class)]
  24. #[Table(name'`point_transfer_type`')]
  25. class TransferType
  26. {
  27.     #[Id]
  28.     #[Column(type'integer')]
  29.     #[GeneratedValue]
  30.     #[Groups('read')]
  31.     private ?int $id null;
  32.     #[Column(type'string')]
  33.     #[NotBlank]
  34.     #[Groups(['read''write'])]
  35.     private string $name;
  36.     /**
  37.      * @var Collection<int, Transfer>
  38.      */
  39.     #[OneToMany(mappedBy'type'targetEntityTransfer::class)]
  40.     #[Groups('read')]
  41.     #[ApiProperty(readableLinkfalse)]
  42.     private Collection $transfers;
  43.     public function __toString(): string
  44.     {
  45.         return $this->name;
  46.     }
  47.     public function getId(): ?int
  48.     {
  49.         return $this->id;
  50.     }
  51.     public function setId(int $id): void
  52.     {
  53.         $this->id $id;
  54.     }
  55.     public function getName(): string
  56.     {
  57.         return $this->name;
  58.     }
  59.     public function setName(string $name)
  60.     {
  61.         $this->name $name;
  62.     }
  63.     /**
  64.      * @return Collection<int, Transfer>
  65.      */
  66.     public function getTransfers(): Collection
  67.     {
  68.         return $this->transfers;
  69.     }
  70. }