<?php
namespace App\CMSBundle\Entity;
use App\CMSBundle\Entity\Translation\FaqTranslation;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use PN\LocaleBundle\Model\LocaleTrait;
use PN\LocaleBundle\Model\Translatable;
use PN\ServiceBundle\Interfaces\DateTimeInterface;
use PN\ServiceBundle\Model\DateTimeTrait;
/**
* Faq
*
* @ORM\HasLifecycleCallbacks
* @ORM\Table(name="faq")
* @ORM\Entity(repositoryClass="App\CMSBundle\Repository\FaqRepository")
*/
class Faq implements DateTimeInterface, Translatable
{
use DateTimeTrait,
LocaleTrait;
/**
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private ?int $id = null;
/**
* @ORM\Column(name="question", type="text")
*/
private ?string $question = null;
/**
* @ORM\Column(name="answer", type="text")
*/
private ?string $answer = null;
/**
* @ORM\Column(name="publish", type="boolean")
*/
private bool $publish = true;
/**
* @ORM\OneToMany(targetEntity="App\CMSBundle\Entity\Translation\FaqTranslation", mappedBy="translatable", cascade={"ALL"}, orphanRemoval=true)
*/
private Collection $translations;
public function __construct()
{
$this->translations = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getQuestion(): ?string
{
return $this->question;
}
public function setQuestion(string $question): static
{
$this->question = $question;
return $this;
}
public function getAnswer(): ?string
{
return $this->answer;
}
public function setAnswer(string $answer): static
{
$this->answer = $answer;
return $this;
}
public function isPublish(): ?bool
{
return $this->publish;
}
public function setPublish(bool $publish): static
{
$this->publish = $publish;
return $this;
}
/**
* @return Collection<int, FaqTranslation>
*/
public function getTranslations(): Collection
{
return $this->translations;
}
public function addTranslation(FaqTranslation $translation): static
{
if (!$this->translations->contains($translation)) {
$this->translations->add($translation);
$translation->setTranslatable($this);
}
return $this;
}
public function removeTranslation(FaqTranslation $translation): static
{
if ($this->translations->removeElement($translation)) {
// set the owning side to null (unless already changed)
if ($translation->getTranslatable() === $this) {
$translation->setTranslatable(null);
}
}
return $this;
}
}