src/Entity/TagMedia.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\Common\Collections\Collection;
  5. use Doctrine\ORM\Mapping as ORM;
  6. /**
  7.  * @ORM\Entity (repositoryClass="App\Repository\TagMediaRepository")
  8.  */
  9. class TagMedia
  10. {
  11.     public function __construct()
  12.     {
  13.         $this->medias = new ArrayCollection();
  14.     }
  15.     /**
  16.      * @ORM\Id()
  17.      * @ORM\GeneratedValue()
  18.      * @ORM\Column(type="integer")
  19.      */
  20.     private $id;
  21.     /**
  22.      * @ORM\Column(type="string", length=255)
  23.      */
  24.     private $name;
  25.     /**
  26.      * @ORM\ManyToOne(targetEntity="App\Entity\User", inversedBy="mediaTags")
  27.      * @ORM\JoinColumns({
  28.      *   @ORM\JoinColumn(name="owner_id", referencedColumnName="id")
  29.      * })
  30.      */
  31.     private $owner;
  32.     /**
  33.      * @ORM\ManyToOne(targetEntity="App\Entity\DnsitEntity", inversedBy="mediaTags")
  34.      * @ORM\JoinColumns({
  35.      *   @ORM\JoinColumn(name="entity_id", referencedColumnName="id")
  36.      * })
  37.      */
  38.     private $entity;
  39.     /**
  40.      * @ORM\ManyToMany(targetEntity="App\Entity\Media", mappedBy="mediaTags")
  41.      */
  42.     private $medias;
  43.     /**
  44.      * @ORM\Column(type="datetime", nullable=true)
  45.      */
  46.     private $createdAt;
  47.     /**
  48.      * @ORM\Column(type="datetime", nullable=true)
  49.      */
  50.     private $updatedAt;
  51.     public function getId() : ?int
  52.     {
  53.         return $this->id;
  54.     }
  55.     public function getName() : ?string
  56.     {
  57.         return $this->name;
  58.     }
  59.     public function setName(string $name) : self
  60.     {
  61.         $this->name $name;
  62.         return $this;
  63.     }
  64.     public function getOwner() : ?User
  65.     {
  66.         return $this->owner;
  67.     }
  68.     public function setOwner(?User $owner) : self
  69.     {
  70.         $this->owner $owner;
  71.         return $this;
  72.     }
  73.     public function getEntity() : ?DnsitEntity
  74.     {
  75.         return $this->entity;
  76.     }
  77.     public function setEntity(?DnsitEntity $entity) : self
  78.     {
  79.         $this->entity $entity;
  80.         return $this;
  81.     }
  82.     public function getCreatedAt() : ?\DateTimeInterface
  83.     {
  84.         return $this->createdAt;
  85.     }
  86.     public function setCreatedAt(\DateTimeInterface $createdAt) : self
  87.     {
  88.         $this->createdAt $createdAt;
  89.         return $this;
  90.     }
  91.     public function getUpdatedAt() : ?\DateTimeInterface
  92.     {
  93.         return $this->updatedAt;
  94.     }
  95.     public function setUpdatedAt(?\DateTimeInterface $updatedAt) : self
  96.     {
  97.         $this->updatedAt $updatedAt;
  98.         return $this;
  99.     }
  100.     /**
  101.      * @return Collection|Media[]
  102.      */
  103.     public function getMedias() : Collection
  104.     {
  105.         return $this->medias;
  106.     }
  107.     public function addMedia(Media $media) : self
  108.     {
  109.         if (!$this->medias->contains($media)) {
  110.             $this->medias[] = $media;
  111.             $media->addMediaTag($this);
  112.         }
  113.         return $this;
  114.     }
  115.     public function removeMedia(Media $media) : self
  116.     {
  117.         if ($this->medias->contains($media)) {
  118.             $this->medias->removeElement($media);
  119.             $media->removeMediaTag($this);
  120.         }
  121.         return $this;
  122.     }
  123. }