Advertisement
JPunto

Untitled

Nov 15th, 2012
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 8.29 KB | None | 0 0
  1. /******************************************************/
  2. /********************** PREGUNTA **********************/
  3. /******************************************************/
  4.  
  5. <?php
  6.  
  7. namespace W_Encuestas\EncuestasBundle\Entity;
  8.  
  9. use Doctrine\ORM\Mapping as ORM;
  10.  
  11. use Symfony\Component\Validator\Constraints as Assert;
  12.  
  13. /**
  14.  * @ORM\Entity(repositoryClass="W_Encuestas\EncuestasBundle\Entity\Repositorios\PreguntaRepository")
  15.  * @ORM\InheritanceType("JOINED")
  16.  * @ORM\DiscriminatorColumn(name="tipo_pregunta", type="string")
  17.  * @ORM\DiscriminatorMap({"SU" = "SelUnica", "SM" = "SelMultiple", "VE" = "ValorEntero", "VD" = "ValorDecimal", "TX" = "Texto"})
  18.  */
  19. abstract class Pregunta
  20. {
  21.     /**
  22.      * @ORM\Id
  23.      * @ORM\Column(type="integer")
  24.      * @ORM\GeneratedValue(strategy="IDENTITY")
  25.      */
  26.     protected $id;
  27.     /**
  28.      * @ORM\Column(type="integer")
  29.      */
  30.     protected $orden;
  31.     /**
  32.      * @ORM\Column(type="boolean")
  33.      * @Assert\Type(type="boolean", message="El valor de 'Respuesta obligatoria' no es correcto")
  34.      */
  35.     protected $respuesta_obligatoria;
  36.     /**
  37.      * @ORM\Column(type="string")
  38.      * @Assert\NotBlank(message="El campo 'Texto' es obligatorio")
  39.      */
  40.     protected $texto;
  41.     /**
  42.      * @ORM\ManyToOne(targetEntity="Encuesta", inversedBy="preguntas")
  43.      * @ORM\JoinColumn(name="encuesta_id", referencedColumnName="id")
  44.      */
  45.     protected $encuesta;
  46.  
  47.     /**
  48.      * Get id
  49.      *
  50.      * @return integer
  51.      */
  52.     public function getId()
  53.     {
  54.         return $this->id;
  55.     }
  56.  
  57.     /**
  58.      * Set orden
  59.      *
  60.      * @param integer $orden
  61.      */
  62.     public function setOrden($orden)
  63.     {
  64.         $this->orden = $orden;
  65.     }
  66.  
  67.     /**
  68.      * Get orden
  69.      *
  70.      * @return integer
  71.      */
  72.     public function getOrden()
  73.     {
  74.         return $this->orden;
  75.     }
  76.  
  77.     /**
  78.      * Set respuesta_obligatoria
  79.      *
  80.      * @param boolean $respuestaObligatoria
  81.      */
  82.     public function setRespuestaObligatoria($respuestaObligatoria)
  83.     {
  84.         $this->respuesta_obligatoria = $respuestaObligatoria;
  85.     }
  86.  
  87.     /**
  88.      * Get respuesta_obligatoria
  89.      *
  90.      * @return boolean
  91.      */
  92.     public function getRespuestaObligatoria()
  93.     {
  94.         return $this->respuesta_obligatoria;
  95.     }
  96.  
  97.     /**
  98.      * Set encuesta
  99.      *
  100.      * @param W_Encuestas\EncuestasBundle\Entity\Encuesta $encuesta
  101.      */
  102.     public function setEncuesta(\W_Encuestas\EncuestasBundle\Entity\Encuesta $encuesta)
  103.     {
  104.         $this->encuesta = $encuesta;
  105.     }
  106.  
  107.     /**
  108.      * Get encuesta
  109.      *
  110.      * @return W_Encuestas\EncuestasBundle\Entity\Encuesta
  111.      */
  112.     public function getEncuesta()
  113.     {
  114.         return $this->encuesta;
  115.     }
  116.    
  117.     /**
  118.      * Get tipo_pregunta
  119.      *
  120.      * @return string
  121.      */
  122.     public function getTipoPregunta()
  123.     {
  124.         return $this->tipo_pregunta;
  125.     }
  126.  
  127.     /**
  128.      * Set texto
  129.      *
  130.      * @param string $texto
  131.      */
  132.     public function setTexto($texto)
  133.     {
  134.         $this->texto = $texto;
  135.     }
  136.  
  137.     /**
  138.      * Get texto
  139.      *
  140.      * @return string
  141.      */
  142.     public function getTexto()
  143.     {
  144.         return $this->texto;
  145.     }
  146. }
  147.  
  148.  
  149. /******************************************************/
  150. /********************** SELECCION *********************/
  151. /******************************************************/
  152. <?php
  153.  
  154. namespace W_Encuestas\EncuestasBundle\Entity;
  155.  
  156. use Doctrine\ORM\Mapping as ORM;
  157.  
  158. use Doctrine\Common\Collections\ArrayCollection;
  159.  
  160. use Symfony\Component\Validator\Constraints as Assert;
  161.  
  162. /**
  163.  * @ORM\Entity
  164.  */
  165. abstract class Seleccion extends Pregunta
  166. {
  167.     /**
  168.      * @ORM\Column(type="string")
  169.      * @Assert\NotBlank(message="Debe seleccionarse una opción para 'Tipo presentación'")
  170.      * @Assert\Choice(choices={"Horizontal", "Vertical"}, message="El valor de 'Tipo presentación' no es correcto")
  171.      */
  172.     protected $tipo_presentacion;
  173.     /**
  174.      * @ORM\Column(type="boolean")
  175.      * @Assert\Type(type="boolean", message="El valor de 'Opciones con imágenes' no es correcto")
  176.      */
  177.     protected $opciones_con_imagenes;
  178.     /**
  179.      * @ORM\OneToMany(targetEntity="Opcion", mappedBy="seleccion")
  180.      */
  181.     protected $opciones;
  182.  
  183.     public function __construct()
  184.     {
  185.         $this->opciones = new \Doctrine\Common\Collections\ArrayCollection();
  186.     }
  187.  
  188.     /**
  189.      * Set tipo_presentacion
  190.      *
  191.      * @param string $tipoPresentacion
  192.      */
  193.     public function setTipoPresentacion($tipoPresentacion)
  194.     {
  195.         $this->tipo_presentacion = $tipoPresentacion;
  196.     }
  197.  
  198.     /**
  199.      * Get tipo_presentacion
  200.      *
  201.      * @return string
  202.      */
  203.     public function getTipoPresentacion()
  204.     {
  205.         return $this->tipo_presentacion;
  206.     }
  207.    
  208.     /**
  209.      * Set opciones_con_imagenes
  210.      *
  211.      * @param boolean $opcionesConImagenes
  212.      */
  213.     public function setOpcionesConImagenes($opcionesConImagenes)
  214.     {
  215.         $this->opciones_con_imagenes = $opcionesConImagenes;
  216.     }
  217.  
  218.     /**
  219.      * Get opciones_con_imagenes
  220.      *
  221.      * @return boolean
  222.      */
  223.     public function getOpcionesConImagenes()
  224.     {
  225.         return $this->opciones_con_imagenes;
  226.     }
  227.  
  228.     /**
  229.      * Add opciones
  230.      *
  231.      * @param W_Encuestas\EncuestasBundle\Entity\Opcion $opciones
  232.      */
  233.     public function addOpcion(\W_Encuestas\EncuestasBundle\Entity\Opcion $opciones)
  234.     {
  235.         $this->opciones[] = $opciones;
  236.     }
  237.    
  238.     public function setOpciones(ArrayCollection $opciones)
  239.     {
  240.         $this->opciones = $opciones;
  241.     }
  242.  
  243.     /**
  244.      * Get opciones
  245.      *
  246.      * @return Doctrine\Common\Collections\Collection
  247.      */
  248.     public function getOpciones()
  249.     {
  250.         return $this->opciones;
  251.     }
  252. }
  253.  
  254.  
  255. /******************************************************/
  256. /********************** SELUNICA **********************/
  257. /******************************************************/
  258. <?php
  259.  
  260. namespace W_Encuestas\EncuestasBundle\Entity;
  261.  
  262. use Doctrine\ORM\Mapping as ORM;
  263.  
  264. use Doctrine\Common\Collections\ArrayCollection;
  265.  
  266. use Symfony\Component\Validator\Constraints as Assert;
  267.  
  268. /**
  269.  * @ORM\Entity
  270.  */
  271. class SelUnica extends Seleccion
  272. {  
  273.     public function __construct()
  274.     {
  275.         $this->opciones = new \Doctrine\Common\Collections\ArrayCollection();
  276.     }
  277.  
  278.     /**
  279.      * Get tipo_pregunta
  280.      *
  281.      * @var string
  282.      */
  283.     public function getTipoPregunta()
  284.     {
  285.         return 'SU';
  286.     }
  287. }
  288.  
  289.  
  290. /******************************************************/
  291. /********************* SELMULTIPLE ********************/
  292. /******************************************************/
  293. <?php
  294.  
  295. namespace W_Encuestas\EncuestasBundle\Entity;
  296.  
  297. use Doctrine\ORM\Mapping as ORM;
  298.  
  299. use Doctrine\Common\Collections\ArrayCollection;
  300.  
  301. use Symfony\Component\Validator\Constraints as Assert;
  302.  
  303. /**
  304.  * @ORM\Entity
  305.  */
  306. class SelMultiple extends Seleccion
  307. {
  308.     /**
  309.      * @ORM\Column(type="integer", nullable=true)
  310.      * @Assert\Type(type="numeric", message="El número mínimo de respuestas tiene que ser numérico")
  311.      */
  312.     protected $min_respuestas;
  313.     /**
  314.      * @ORM\Column(type="integer", nullable=true)
  315.      * @Assert\Type(type="numeric", message="El número máximo de respuestas tiene que ser numérico")
  316.      */
  317.     protected $max_respuestas;
  318.  
  319.     public function __construct()
  320.     {
  321.         $this->opciones = new \Doctrine\Common\Collections\ArrayCollection();
  322.     }
  323.    
  324.     /**
  325.      * Set min_respuestas
  326.      *
  327.      * @param integer $minRespuestas
  328.      */
  329.     public function setMinRespuestas($minRespuestas)
  330.     {
  331.         $this->min_respuestas = $minRespuestas;
  332.     }
  333.  
  334.     /**
  335.      * Get min_respuestas
  336.      *
  337.      * @return integer
  338.      */
  339.     public function getMinRespuestas()
  340.     {
  341.         return $this->min_respuestas;
  342.     }
  343.  
  344.     /**
  345.      * Set max_respuestas
  346.      *
  347.      * @param integer $maxRespuestas
  348.      */
  349.     public function setMaxRespuestas($maxRespuestas)
  350.     {
  351.         $this->max_respuestas = $maxRespuestas;
  352.     }
  353.  
  354.     /**
  355.      * Get max_respuestas
  356.      *
  357.      * @return integer
  358.      */
  359.     public function getMaxRespuestas()
  360.     {
  361.         return $this->max_respuestas;
  362.     }
  363.    
  364.     /**
  365.      * Get tipo_pregunta
  366.      *
  367.      * @var string
  368.      */
  369.     public function getTipoPregunta()
  370.     {
  371.         return 'SM';
  372.     }
  373. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement