src/AtechNet/CoreBundle/Entity/SurveyQuestion.php line 18

Open in your IDE?
  1. <?php
  2. namespace App\AtechNet\CoreBundle\Entity;
  3. use Doctrine\Common\Collections\ArrayCollection;
  4. use Doctrine\ORM\Mapping\Column;
  5. use Doctrine\ORM\Mapping\Entity;
  6. use Doctrine\ORM\Mapping\JoinColumn;
  7. use Doctrine\ORM\Mapping\ManyToOne;
  8. use Doctrine\ORM\Mapping\OneToMany;
  9. use Doctrine\ORM\Mapping\OrderBy;
  10. use Doctrine\ORM\Mapping\Table as Table;
  11. /**
  12.  * @Table(name="survey_questions")
  13.  * @Entity()
  14.  */
  15. class SurveyQuestion extends AbstractSignedEntity
  16. {
  17.     public const TYPE_SHORT_TEXT = 1;
  18.     public const TYPE_LONG_TEXT = 2;
  19.     public const TYPE_OPTIONS = 3;
  20.     public const TYPE_CHECKBOXES = 4;
  21.     public const TYPE_SCALE = 5;
  22.     /**
  23.      * @return array
  24.      */
  25.     public static function getTypeChoices()
  26.     {
  27.         return [
  28.             self::TYPE_SHORT_TEXT => 'short text',
  29.             self::TYPE_LONG_TEXT => 'long text',
  30.             self::TYPE_OPTIONS => 'options',
  31.             self::TYPE_CHECKBOXES => 'checkboxes',
  32.             self::TYPE_SCALE => 'scale',
  33.         ];
  34.     }
  35.     /**
  36.      * @var Survey
  37.      *
  38.      * @ManyToOne(targetEntity="Survey", inversedBy="questions")
  39.      * @JoinColumn(name="survey_id", referencedColumnName="id")
  40.      */
  41.     private $survey;
  42.     /**
  43.      * @var int
  44.      *
  45.      * @Column(name="type", type="integer")
  46.      */
  47.     private $type;
  48.     /**
  49.      * @var string
  50.      *
  51.      * @Column(name="question", type="text", nullable=false)
  52.      */
  53.     private $question;
  54.     /**
  55.      * @var int
  56.      *
  57.      * @Column(name="sort_index", type="integer")
  58.      */
  59.     private $sortIndex;
  60.     /**
  61.      * @var ArrayCollection
  62.      *
  63.      * @OneToMany(targetEntity="SurveyQuestionOption", mappedBy="question", orphanRemoval=true)
  64.      * @OrderBy({"sortIndex" = "ASC"})
  65.      **/
  66.     private $options;
  67.     /**
  68.      * @var ArrayCollection
  69.      *
  70.      * @OneToMany(targetEntity="SurveyAnswer", mappedBy="question", orphanRemoval=true)
  71.      * @OrderBy({"created" = "DESC"})
  72.      **/
  73.     private $answers;
  74.     /**
  75.      * @var ArrayCollection
  76.      *
  77.      * @OneToMany(targetEntity="SurveyMedia", mappedBy="question", orphanRemoval=true)
  78.      * @OrderBy({"created" = "DESC"})
  79.      **/
  80.     private $medias;
  81.     /**
  82.      * @return Survey
  83.      */
  84.     public function getSurvey()
  85.     {
  86.         return $this->survey;
  87.     }
  88.     /**
  89.      * @param Survey $survey
  90.      */
  91.     public function setSurvey($survey)
  92.     {
  93.         $this->survey = $survey;
  94.     }
  95.     /**
  96.      * @return int
  97.      */
  98.     public function getType()
  99.     {
  100.         return $this->type;
  101.     }
  102.     /**
  103.      * @param int $type
  104.      */
  105.     public function setType($type)
  106.     {
  107.         $this->type = $type;
  108.     }
  109.     /**
  110.      * @return string
  111.      */
  112.     public function getQuestion()
  113.     {
  114.         return $this->question;
  115.     }
  116.     /**
  117.      * @param string $question
  118.      */
  119.     public function setQuestion($question)
  120.     {
  121.         $this->question = $question;
  122.     }
  123.     /**
  124.      * @return int
  125.      */
  126.     public function getSortIndex()
  127.     {
  128.         return $this->sortIndex;
  129.     }
  130.     /**
  131.      * @param int $sortIndex
  132.      */
  133.     public function setSortIndex($sortIndex)
  134.     {
  135.         $this->sortIndex = $sortIndex;
  136.     }
  137.     /**
  138.      * @return ArrayCollection
  139.      */
  140.     public function getOptions()
  141.     {
  142.         return $this->options;
  143.     }
  144.     /**
  145.      * @return ArrayCollection
  146.      */
  147.     public function getAnswers()
  148.     {
  149.         return $this->answers;
  150.     }
  151.     /**
  152.      * @return ArrayCollection
  153.      */
  154.     public function getMedias()
  155.     {
  156.         return $this->medias;
  157.     }
  158. }