<?php
namespace App\Entity;
use App\Repository\IdeaBoxQuestionRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
use JMS\Serializer\Annotation as Serializer;
use JMS\Serializer\Annotation\Expose;
use JMS\Serializer\Annotation\Groups;
/**
* @ORM\Entity(repositoryClass=IdeaBoxQuestionRepository::class)
*
* @Serializer\ExclusionPolicy("ALL")
*/
class IdeaBoxQuestion
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*
* @Expose
* @Groups({
* "idea_box_question:id",
* "idea_box_list", "idea_box_stats", "export_idea_box_datatable"
* })
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=IdeaBox::class, inversedBy="questions")
*
* @Expose
* @Groups({
* "idea_box_question:idea_box",
* "export_idea_box_datatable"
* })
*/
private ?IdeaBox $ideaBox;
/**
* @ORM\OneToMany(targetEntity=IdeaBoxAnswer::class, mappedBy="ideaBoxQuestion", cascade={"remove"})
*
* @Expose
* @Groups({
* "idea_box_question:answers",
* "export_idea_box_datatable"
* })
*/
private $answers;
/**
* @ORM\Column(type="boolean")
*/
private $enabled;
/**
* @ORM\Column(type="text")
*
* @Expose
* @Groups({
* "idea_box_question:question",
* "export_idea_box_datatable"
* })
*/
private ?string $question;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*
* @Expose
* @Groups({
* "idea_box_question:type",
* "idea_box_stats", "export_idea_box_datatable"
* })
*/
private ?string $type;
/**
* @ORM\OneToMany(targetEntity=IdeaBoxRecipient::class, mappedBy="ideaBoxQuestion")
*
* @Expose
* @Groups({
* "idea_box_question:idea_box_recipients",
* "export_idea_box_datatable"
* })
*/
private $ideaBoxRecipients;
public function __construct()
{
$this->answers = new ArrayCollection();
$this->ideaBoxRecipients = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getIdeaBox(): ?IdeaBox
{
return $this->ideaBox;
}
public function setIdeaBox( ?IdeaBox $ideaBox ): IdeaBoxQuestion
{
$this->ideaBox = $ideaBox;
return $this;
}
public function getAnswers(): Collection
{
return $this->answers;
}
public function addAnswer( IdeaBoxAnswer $answer ): IdeaBoxQuestion
{
if ( !$this->answers->contains( $answer ) ) {
$this->answers[] = $answer;
$answer->setIdeaBoxQuestion( $this );
}
return $this;
}
public function removeAnswer( IdeaBoxAnswer $answer ): IdeaBoxQuestion
{
if ( $this->answers->removeElement( $answer ) ) {
// set the owning side to null (unless already changed)
if ( $answer->getIdeaBoxQuestion() === $this ) {
$answer->setIdeaBoxQuestion( NULL );
}
}
return $this;
}
public function isEnabled(): ?bool
{
return $this->enabled;
}
public function setEnabled( bool $enabled ): IdeaBoxQuestion
{
$this->enabled = $enabled;
return $this;
}
public function getQuestion(): ?string
{
return $this->question;
}
public function setQuestion( string $question ): IdeaBoxQuestion
{
$this->question = $question;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType( ?string $type ): IdeaBoxQuestion
{
$this->type = $type;
return $this;
}
/**
* @return Collection<int, IdeaBoxRecipient>
*/
public function getIdeaBoxRecipients(): Collection
{
return $this->ideaBoxRecipients;
}
public function addIdeaBoxRecipient( IdeaBoxRecipient $ideaBoxRecipient ): IdeaBoxQuestion
{
if ( !$this->ideaBoxRecipients->contains( $ideaBoxRecipient ) ) {
$this->ideaBoxRecipients[] = $ideaBoxRecipient;
$ideaBoxRecipient->setIdeaBoxQuestion( $this );
}
return $this;
}
public function removeIdeaBoxRecipient( IdeaBoxRecipient $ideaBoxRecipient ): IdeaBoxQuestion
{
if ( $this->ideaBoxRecipients->removeElement( $ideaBoxRecipient ) ) {
// set the owning side to null (unless already changed)
if ( $ideaBoxRecipient->getIdeaBoxQuestion() === $this ) {
$ideaBoxRecipient->setIdeaBoxQuestion( NULL );
}
}
return $this;
}
}