src/Entity/Chat/Resource.php line 15

Open in your IDE?
  1. <?php
  2. namespace App\Entity\Chat;
  3. use App\Entity\Channel\Channel;
  4. use App\Repository\ResourceRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Drosalys\Bundle\ApiBundle\Serializer\Attributes\IdGroups;
  9. use Symfony\Component\Serializer\Annotation as Serial;
  10. #[ORM\Entity(repositoryClassResourceRepository::class)]
  11. #[ORM\Table(name'chat_resources')]
  12. class Resource
  13. {
  14.     #[
  15.         ORM\IdORM\GeneratedValue,
  16.         ORM\Column(type'integer'),
  17.     ]
  18.     #[Serial\Groups(['Resource'])]
  19.     #[IdGroups(groups: ['PostCanal'])]
  20.     protected ?int $id null;
  21.     #[ORM\ManyToMany(targetEntityCanal::class, mappedBy'resources')]
  22.     private Collection $canals;
  23.     #[ORM\Column(type'string'nullablefalse)]
  24.     #[Serial\Groups(['Resource'])]
  25.     private ?string $dtype null;
  26.     #[ORM\ManyToOne(targetEntityChannel::class)]
  27.     #[ORM\JoinColumn(nullablefalseonDelete'CASCADE')]
  28.     private ?Channel $channel null;
  29.     public function __construct()
  30.     {
  31.         $this->canals = new ArrayCollection();
  32.     }
  33.     public function getId(): ?int
  34.     {
  35.         return $this->id;
  36.     }
  37.     /**
  38.      * @return Collection<int, Canal>
  39.      */
  40.     public function getCanals(): Collection
  41.     {
  42.         return $this->canals ?? $this->canals = new ArrayCollection();
  43.     }
  44.     public function addCanal(Canal $canal): self
  45.     {
  46.         if (!$this->getCanals()->contains($canal)) {
  47.             $this->getCanals()->add($canal);
  48.             $canal->addResource($this);
  49.         }
  50.         return $this;
  51.     }
  52.     public function removeCanal(Canal $canal): self
  53.     {
  54.         if ($this->canals->removeElement($canal)) {
  55.             // set the owning side to null (unless already changed)
  56.             if ($canal->getResources()->contains($this)) {
  57.                 $canal->removeResource($this);
  58.             }
  59.         }
  60.         return $this;
  61.     }
  62.     public function getDtype(): ?string
  63.     {
  64.         return $this->dtype;
  65.     }
  66.     public function setDtype(?string $dtype): Resource
  67.     {
  68.         $this->dtype $dtype;
  69.         return $this;
  70.     }
  71.     public function getChannel(): ?Channel
  72.     {
  73.         return $this->channel;
  74.     }
  75.     public function setChannel(?Channel $channel): Resource
  76.     {
  77.         $this->channel $channel;
  78.         return $this;
  79.     }
  80. }