src/Entity/CampaignType.php line 18

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Entity;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Symfony\Component\Serializer\Annotation\Groups;
  8. /**
  9.  * CampaignType
  10.  *
  11.  * @ORM\Table(name="campaign_type")
  12.  * @ORM\Entity
  13.  */
  14. class CampaignType
  15. {
  16.     public const SERIALIZATION_GROUP_LISTING 'campaign_type_listing';
  17.     /**
  18.      * @var int
  19.      *
  20.      * @ORM\Column(name="id", type="smallint", nullable=false)
  21.      * @ORM\Id
  22.      * @ORM\GeneratedValue(strategy="IDENTITY")
  23.      * @Groups({self::SERIALIZATION_GROUP_LISTING})
  24.      */
  25.     private $id;
  26.     /**
  27.      * @var string
  28.      *
  29.      * @ORM\Column(name="name", type="string", length=40, nullable=false)
  30.      * @Groups({self::SERIALIZATION_GROUP_LISTING})
  31.      */
  32.     private $name;
  33.     /**
  34.      * @var Collection
  35.      * 
  36.      * @ORM\OneToMany(targetEntity=CampaignTypeStatus::class, mappedBy="campaignType")
  37.      */
  38.     private $status;
  39.     /**
  40.      * Constructor
  41.      */
  42.     public function __construct()
  43.     {
  44.         $this->status = new ArrayCollection();
  45.     }
  46.     public function getId(): ?int
  47.     {
  48.         return $this->id;
  49.     }
  50.     public function getName(): ?string
  51.     {
  52.         return $this->name;
  53.     }
  54.     public function setName(string $name): self
  55.     {
  56.         $this->name $name;
  57.         return $this;
  58.     }
  59.     /**
  60.      * @return Collection<int, CampaignTypeStatus>
  61.      */
  62.     public function getStatus(): Collection
  63.     {
  64.         return $this->status;
  65.     }
  66.     public function addStatus(CampaignTypeStatus $status): self
  67.     {
  68.         if (!$this->status->contains($status)) {
  69.             $this->status[] = $status;
  70.             $status->setCampaignType($this);
  71.         }
  72.         return $this;
  73.     }
  74.     public function removeStatus(CampaignTypeStatus $status): self
  75.     {
  76.         if ($this->status->removeElement($status)) {
  77.             // set the owning side to null (unless already changed)
  78.             if ($status->getCampaignType() === $this) {
  79.                 $status->setCampaignType(null);
  80.             }
  81.         }
  82.         return $this;
  83.     }
  84. }