src/Entity/Interview.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\InterviewRepository;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Gedmo\Mapping\Annotation as Gedmo;
  6. use Gedmo\SoftDeleteable\Traits\SoftDeleteableEntity;
  7. use Gedmo\Timestampable\Traits\TimestampableEntity;
  8. use Gedmo\Translatable\Translatable;
  9. use Doctrine\Common\Collections\ArrayCollection;
  10. use App\Entity\Translation\InterviewTranslation;
  11. use Symfony\Component\Serializer\Annotation\Ignore;
  12. use Symfony\Component\Serializer\Annotation\Groups;
  13. /**
  14.  * @ORM\Entity(repositoryClass=InterviewRepository::class)
  15.  * @Gedmo\TranslationEntity(class="App\Entity\Translation\InterviewTranslation")
  16.  * @Gedmo\SoftDeleteable(fieldName="deletedAt", timeAware=false, hardDelete=true)
  17.  */
  18. class Interview implements Translatable
  19. {
  20.     use SoftDeleteableEntity;
  21.     use TimestampableEntity;
  22.     use SetTranslationsTrait;
  23.     public const FIELDS = [
  24.         'title'
  25.      ];
  26.     /**
  27.      * @ORM\Id
  28.      * @ORM\GeneratedValue
  29.      * @ORM\Column(type="integer")
  30.      * @Groups("interview:list", "interview:item")
  31.      */
  32.     private $id;
  33.     /**
  34.      * @ORM\Column(type="string", length=255)
  35.      * @Gedmo\Translatable
  36.      * @Groups("interview:list", "interview:item")
  37.      */
  38.     private $title;
  39.     /**
  40.      * @var string
  41.      * @Ignore()
  42.      */
  43.     private $titleEn;
  44.     /**
  45.      * @var string
  46.      * @Ignore()
  47.      */
  48.     private $titleCa;
  49.     /**
  50.      * @ORM\Column(type="string", length=255)
  51.      * @Groups("interview:list", "interview:item")
  52.      */
  53.     private $url;
  54.     /**
  55.     * @ORM\OneToMany(
  56.     *   targetEntity="App\Entity\Translation\InterviewTranslation",
  57.     *   mappedBy="object",
  58.     *   cascade={"persist", "remove"}
  59.     * )
  60.      * @Ignore()
  61.     */
  62.     private $translations;
  63.     /**
  64.     * Behind constructor.
  65.     */
  66.     public function __construct()
  67.     {
  68.         $this->translations = new ArrayCollection();
  69.     }
  70.     public function getId(): ?int
  71.     {
  72.         return $this->id;
  73.     }
  74.     public function getTitle(): ?string
  75.     {
  76.         return $this->title;
  77.     }
  78.     public function setTitle(string $title): self
  79.     {
  80.         $this->title $title;
  81.         return $this;
  82.     }
  83.     /**
  84.      * @return mixed
  85.      */
  86.     public function getTitleEn()
  87.     {
  88.         return $this->titleEn;
  89.     }
  90.     /**
  91.      * @param string|null $titleEn
  92.      *
  93.      * @return $this
  94.      */
  95.     public function setTitleEn(?string $titleEn): self
  96.     {
  97.         $this->titleEn $titleEn;
  98.         return $this;
  99.     }
  100.     /**
  101.      * @return mixed
  102.      */
  103.     public function getTitleCa()
  104.     {
  105.         return $this->titleCa;
  106.     }
  107.     /**
  108.      * @param string|null $titleCa
  109.      *
  110.      * @return $this
  111.      */
  112.     public function setTitleCa(?string $titleCa): self
  113.     {
  114.         $this->titleCa $titleCa;
  115.         return $this;
  116.     }
  117.     /**
  118.      * @return mixed
  119.      */
  120.     public function getUrl()
  121.     {
  122.         return $this->url;
  123.     }
  124.     /**
  125.      * @param mixed $url
  126.      */
  127.     public function setUrl($url): void
  128.     {
  129.         $this->url $url;
  130.     }
  131.     /**
  132.      * @Gedmo\Locale
  133.      * Used locale to override Translation listener`s locale
  134.      * this is not a mapped field of entity metadata, just a simple property
  135.      */
  136.     private $locale;
  137.     public function setTranslatableLocale($locale)
  138.     {
  139.         $this->locale $locale;
  140.     }
  141.     public function getTranslations()
  142.     {
  143.         return $this->translations;
  144.     }
  145.     public function addTranslation(InterviewTranslation $t)
  146.     {
  147.         if (!$this->translations->contains($t)) {
  148.             $this->translations[] = $t;
  149.             $t->setObject($this);
  150.         }
  151.     }
  152. }