<?php
namespace App\Entity;
use Gedmo\Mapping\Annotation as Gedmo;
use Doctrine\ORM\Mapping as ORM;
/**
* Question
*
* @ORM\Table(name="question")
* @ORM\Entity(repositoryClass="App\Repository\QuestionRepository")
*/
class Question
{
const TYPES = [
'email',
'phone',
'text',
'comment',
'date',
'datetime',
'number',
'list',
'list_multiple',
'list_checkbox',
'bool'
];
/**
* @var int
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="AUTO")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity="Survey", inversedBy="questions" , cascade={"persist"})
* @ORM\JoinColumn(name="survey_id", referencedColumnName="id", onDelete="SET NULL")
*/
private $survey;
/**
*
* @ORM\OneToMany(targetEntity="Choice", mappedBy="question", cascade={"persist"}, orphanRemoval=true)
* @Orm\OrderBy({"position" = "ASC"})
*/
private $choices;
/**
* @var string
*
* @ORM\Column(name="type", type="string", length=255)
*/
private $type;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255)
*/
private $name;
/**
*
* @ORM\OneToMany(targetEntity="Answer", mappedBy="question")
*/
private $answers;
/**
* @var string
* @Gedmo\SortablePosition
* @ORM\Column(name="position", type="integer")
*/
private $position;
/**
* @var string
*
* @ORM\Column(name="exportName", type="string", length=255)
*/
private $exportName;
/**
* Get id
*
* @return int
*/
public function getId()
{
return $this->id;
}
/**
* Set survey
*
* @param integer $survey
*
* @return Question
*/
public function setSurvey($survey)
{
$this->survey = $survey;
return $this;
}
/**
* Get survey
*
* @return int
*/
public function getSurvey()
{
return $this->survey;
}
/**
* Set choices
*
* @param \App\Entity\Choice $choices
*
* @return Question
*/
public function setChoices(\App\Entity\Choice $choices)
{
$this->choices = $choices;
return $this;
}
/**
* Get choices
*
* @return int
*/
public function getChoices()
{
return $this->choices;
}
/**
* Set type
*
* @param string $type
*
* @return Question
*/
public function setType($type)
{
$this->type = $type;
return $this;
}
/**
* Get type
*
* @return string
*/
public function getType()
{
return $this->type;
}
/**
* Set name
*
* @param string $name
*
* @return Question
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set position
*
* @param string $position
*
* @return Question
*/
public function setPosition($position)
{
$this->position = $position;
return $this;
}
/**
* Get position
*
* @return string
*/
public function getPosition()
{
return $this->position;
}
/**
* Set exportName
*
* @param integer $exportName
*
* @return Question
*/
public function setExportName($exportName)
{
$this->exportName = $exportName;
return $this;
}
/**
* Get exportName
*
* @return string
*/
public function getExportName()
{
return $this->exportName;
}
/**
* Constructor
*/
public function __construct()
{
$this->choices = new \Doctrine\Common\Collections\ArrayCollection();
$this->answers = new \Doctrine\Common\Collections\ArrayCollection();
}
/**
* Add choice
*
* @param \App\Entity\Choice $choice
*
* @return Question
*/
public function addChoice(\App\Entity\Choice $choice)
{
$choice->addQuestion($this);
$this->choices[] = $choice;
return $this;
}
/**
* Remove choice
*
* @param \App\Entity\Choice $choice
*/
public function removeChoice(\App\Entity\Choice $choice)
{
$this->choices->removeElement($choice);
}
/**
* Add answer
*
* @param \App\Entity\Answer $answer
*
* @return Question
*/
public function addAnswer(\App\Entity\Answer $answer)
{
$this->answers[] = $answer;
return $this;
}
/**
* Remove answer
*
* @param \App\Entity\Answer $answer
*/
public function removeAnswer(\App\Entity\Answer $answer)
{
$this->answers->removeElement($answer);
}
/**
* Get answers
*
* @return \Doctrine\Common\Collections\Collection
*/
public function getAnswers()
{
return $this->answers;
}
/**
* Add survey
*
* @param \App\Entity\Survey $survey
*
* @return Question
*/
public function addSurvey(\App\Entity\Survey $survey)
{
$this->survey = $survey;
}
public function __toString()
{
return $this->getName();
}
}