src/Entity/Frequency.php line 45

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use ApiPlatform\Metadata\Get;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use ApiPlatform\Metadata\ApiResource;
  6. use ApiPlatform\Metadata\Delete;
  7. use ApiPlatform\Metadata\GetCollection;
  8. use ApiPlatform\Metadata\Post;
  9. use ApiPlatform\Metadata\Put;
  10. use App\Controller\Api\FrequencyPostAction;
  11. use App\Controller\Api\FrequencyPutAction;
  12. use App\Repository\FrequencyRepository;
  13. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  14. use Symfony\Component\Serializer\Annotation\Groups;
  15. use Symfony\Component\Validator\Constraints as Assert;
  16. #[ORM\Entity(repositoryClassFrequencyRepository::class)]
  17. #[ApiResource(
  18.     operations: [
  19.         new Get(openapifalsenormalizationContext: ['groups' => 'item']),
  20.         new GetCollection(openapifalsenormalizationContext: ['groups' => 'list']),
  21.         new Delete(openapifalsesecurity"is_granted('ROLE_USER')"),
  22.         new Post(
  23.             controllerFrequencyPostAction::class,
  24.             openapifalse,
  25.             security"is_granted('ROLE_USER')",
  26.             deserializefalse
  27.         ),
  28.         new Post(
  29.             uriTemplate'/frequencies/{id}',
  30.             controllerFrequencyPutAction::class,
  31.             openapifalse,
  32.             security"is_granted('ROLE_USER')",
  33.             deserializefalse
  34.         )
  35.     ],
  36. )]
  37. #[UniqueEntity(
  38.     fields: ['region''radio'],
  39.     message'Регион уже существует.',
  40.     errorPath'region',
  41. )]
  42. class Frequency
  43. {
  44.     #[ORM\Id]
  45.     #[ORM\GeneratedValue]
  46.     #[ORM\Column]
  47.     #[Groups(['item''list'])]
  48.     private ?int $id null;
  49.     #[ORM\ManyToOne]
  50.     #[ORM\JoinColumn(nullablefalse)]
  51.     #[Groups(['item''list'])]
  52.     #[Assert\NotNull()]
  53.     private ?Region $region null;
  54.     #[ORM\Column(length255)]
  55.     #[Groups(['item''list'])]
  56.     #[Assert\NotNull()]
  57.     private ?string $frequency null;
  58.     #[ORM\Column(length255nullabletrue)]
  59.     #[Groups(['item''list'])]
  60.     private ?string $sdStream null;
  61.     #[ORM\Column(length255nullabletrue)]
  62.     #[Groups(['item''list'])]
  63.     private ?string $hdStream null;
  64.     #[ORM\ManyToOne(inversedBy'frequencies')]
  65.     #[ORM\JoinColumn(nullablefalse)]
  66.     private ?Radio $radio null;
  67.     public function getId(): ?int
  68.     {
  69.         return $this->id;
  70.     }
  71.     public function getRegion(): ?Region
  72.     {
  73.         return $this->region;
  74.     }
  75.     public function setRegion(?Region $region): self
  76.     {
  77.         $this->region $region;
  78.         return $this;
  79.     }
  80.     public function getFrequency(): ?string
  81.     {
  82.         return str_replace('.'','$this->frequency);
  83.     }
  84.     public function setFrequency(?string $frequency): self
  85.     {
  86.         $this->frequency $frequency;
  87.         return $this;
  88.     }
  89.     public function getSdStream(): ?string
  90.     {
  91.         return $this->sdStream ?: '';
  92.     }
  93.     public function setSdStream(?string $sdStream): self
  94.     {
  95.         $this->sdStream $sdStream;
  96.         return $this;
  97.     }
  98.     public function getHdStream(): ?string
  99.     {
  100.         return $this->hdStream ?: '';
  101.     }
  102.     public function setHdStream(?string $hdStream): self
  103.     {
  104.         $this->hdStream $hdStream;
  105.         return $this;
  106.     }
  107.     public function getRadio(): ?Radio
  108.     {
  109.         return $this->radio;
  110.     }
  111.     public function setRadio(?Radio $radio): self
  112.     {
  113.         $this->radio $radio;
  114.         return $this;
  115.     }
  116.     public function setFakeId(int $id)
  117.     {
  118.         $this->id $id;
  119.     }
  120. }