src/Entity/SponsorCategory.php line 19

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Entity\Translation\SponsorCategoryTranslation;
  4. use App\Repository\SponsorCategoryRepository;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use Doctrine\Common\Collections\Collection;
  7. use Doctrine\ORM\Mapping as ORM;
  8. use Gedmo\Mapping\Annotation as Gedmo;
  9. use Gedmo\Translatable\Translatable;
  10. use Symfony\Component\Serializer\Annotation\Groups;
  11. use Symfony\Component\Serializer\Annotation\Ignore;
  12. /**
  13.  * @ORM\Entity(repositoryClass=SponsorCategoryRepository::class)
  14.  * @Gedmo\TranslationEntity(class="App\Entity\Translation\SponsorCategoryTranslation")
  15.  */
  16. class SponsorCategory implements Translatable
  17. {
  18.     use SetTranslationsTrait;
  19.     public const FIELDS = [
  20.         'name'
  21.     ];
  22.     /**
  23.      * @ORM\Id
  24.      * @ORM\GeneratedValue
  25.      * @ORM\Column(type="integer")
  26.      * @Groups("sponsorcategory:list", "sponsorcategory:item", "sponsor:list", "sponsor:item")
  27.      */
  28.     private $id;
  29.     /**
  30.      * @ORM\Column(type="string", length=255)
  31.      * @Groups("sponsorcategory:list", "sponsorcategory:item", "sponsor:list", "sponsor:item")
  32.      * @Gedmo\Translatable
  33.      */
  34.     private $name;
  35.     /**
  36.      * @var string
  37.      * @Ignore()
  38.      */
  39.     private $nameEn;
  40.     /**
  41.      * @var string
  42.      * @Ignore()
  43.      */
  44.     private $nameCa;
  45.     /**
  46.      * @ORM\Column(type="integer",nullable=true, name="sort")
  47.      * @Groups("sponsorcategory:list", "sponsorcategory:item", "sponsor:list", "sponsor:item")
  48.      * @var int|null
  49.      */
  50.     private $sort;
  51.     /**
  52.      * @ORM\OneToMany(targetEntity=Sponsor::class, mappedBy="category")
  53.      * @Ignore()
  54.      *
  55.      */
  56.     private $sponsors;
  57.     /**
  58.      * @Gedmo\Locale
  59.      */
  60.     private $locale;
  61.     /**
  62.      * @ORM\OneToMany(
  63.      *   targetEntity="App\Entity\Translation\SponsorCategoryTranslation",
  64.      *   mappedBy="object",
  65.      *   cascade={"persist", "remove"}
  66.      * )
  67.      * @Ignore()
  68.      */
  69.     private $translations;
  70.     public function __construct()
  71.     {
  72.         $this->sponsors = new ArrayCollection();
  73.         $this->translations = new ArrayCollection();
  74.     }
  75.     public function __toString()
  76.     {
  77.         return $this->name;
  78.     }
  79.     public function getId(): ?int
  80.     {
  81.         return $this->id;
  82.     }
  83.     public function getName(): ?string
  84.     {
  85.         return $this->name;
  86.     }
  87.     public function setName(string $name): self
  88.     {
  89.         $this->name $name;
  90.         return $this;
  91.     }
  92.     /**
  93.      * @return Collection|Sponsor[]
  94.      */
  95.     public function getSponsors(): Collection
  96.     {
  97.         return $this->sponsors;
  98.     }
  99.     public function addSponsor(Sponsor $sponsor): self
  100.     {
  101.         if (!$this->sponsors->contains($sponsor)) {
  102.             $this->sponsors[] = $sponsor;
  103.             $sponsor->setCategory($this);
  104.         }
  105.         return $this;
  106.     }
  107.     public function removeSponsor(Sponsor $sponsor): self
  108.     {
  109.         if ($this->sponsors->removeElement($sponsor)) {
  110.             // set the owning side to null (unless already changed)
  111.             if ($sponsor->getCategory() === $this) {
  112.                 $sponsor->setCategory(null);
  113.             }
  114.         }
  115.         return $this;
  116.     }
  117.     public function getNameEn()
  118.     {
  119.         return $this->nameEn;
  120.     }
  121.     public function setNameEn($nameEn): void
  122.     {
  123.         $this->nameEn $nameEn;
  124.     }
  125.     public function getNameCa()
  126.     {
  127.         return $this->nameCa;
  128.     }
  129.     public function setNameCa($nameCa)
  130.     {
  131.         $this->nameCa $nameCa;
  132.     }
  133.     public function setTranslatableLocale($locale)
  134.     {
  135.         $this->locale $locale;
  136.     }
  137.     public function getTranslations()
  138.     {
  139.         return $this->translations;
  140.     }
  141.     public function addTranslation(SponsorCategoryTranslation $t)
  142.     {
  143.         if (!$this->translations->contains($t)) {
  144.             $this->translations[] = $t;
  145.             $t->setObject($this);
  146.         }
  147.     }
  148.     /**
  149.      * @return int|null
  150.      */
  151.     public function getSort(): ?int
  152.     {
  153.         return $this->sort;
  154.     }
  155.     /**
  156.      * @param int|null $sort
  157.      * @return void
  158.      */
  159.     public function setSort(?int $sort): void
  160.     {
  161.         $this->sort $sort;
  162.     }
  163. }