Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /******************************************************/
- /********************** PREGUNTA **********************/
- /******************************************************/
- <?php
- namespace W_Encuestas\EncuestasBundle\Entity;
- use Doctrine\ORM\Mapping as ORM;
- use Symfony\Component\Validator\Constraints as Assert;
- /**
- * @ORM\Entity(repositoryClass="W_Encuestas\EncuestasBundle\Entity\Repositorios\PreguntaRepository")
- * @ORM\InheritanceType("JOINED")
- * @ORM\DiscriminatorColumn(name="tipo_pregunta", type="string")
- * @ORM\DiscriminatorMap({"SU" = "SelUnica", "SM" = "SelMultiple", "VE" = "ValorEntero", "VD" = "ValorDecimal", "TX" = "Texto"})
- */
- abstract class Pregunta
- {
- /**
- * @ORM\Id
- * @ORM\Column(type="integer")
- * @ORM\GeneratedValue(strategy="IDENTITY")
- */
- protected $id;
- /**
- * @ORM\Column(type="integer")
- */
- protected $orden;
- /**
- * @ORM\Column(type="boolean")
- * @Assert\Type(type="boolean", message="El valor de 'Respuesta obligatoria' no es correcto")
- */
- protected $respuesta_obligatoria;
- /**
- * @ORM\Column(type="string")
- * @Assert\NotBlank(message="El campo 'Texto' es obligatorio")
- */
- protected $texto;
- /**
- * @ORM\ManyToOne(targetEntity="Encuesta", inversedBy="preguntas")
- * @ORM\JoinColumn(name="encuesta_id", referencedColumnName="id")
- */
- protected $encuesta;
- /**
- * Get id
- *
- * @return integer
- */
- public function getId()
- {
- return $this->id;
- }
- /**
- * Set orden
- *
- * @param integer $orden
- */
- public function setOrden($orden)
- {
- $this->orden = $orden;
- }
- /**
- * Get orden
- *
- * @return integer
- */
- public function getOrden()
- {
- return $this->orden;
- }
- /**
- * Set respuesta_obligatoria
- *
- * @param boolean $respuestaObligatoria
- */
- public function setRespuestaObligatoria($respuestaObligatoria)
- {
- $this->respuesta_obligatoria = $respuestaObligatoria;
- }
- /**
- * Get respuesta_obligatoria
- *
- * @return boolean
- */
- public function getRespuestaObligatoria()
- {
- return $this->respuesta_obligatoria;
- }
- /**
- * Set encuesta
- *
- * @param W_Encuestas\EncuestasBundle\Entity\Encuesta $encuesta
- */
- public function setEncuesta(\W_Encuestas\EncuestasBundle\Entity\Encuesta $encuesta)
- {
- $this->encuesta = $encuesta;
- }
- /**
- * Get encuesta
- *
- * @return W_Encuestas\EncuestasBundle\Entity\Encuesta
- */
- public function getEncuesta()
- {
- return $this->encuesta;
- }
- /**
- * Get tipo_pregunta
- *
- * @return string
- */
- public function getTipoPregunta()
- {
- return $this->tipo_pregunta;
- }
- /**
- * Set texto
- *
- * @param string $texto
- */
- public function setTexto($texto)
- {
- $this->texto = $texto;
- }
- /**
- * Get texto
- *
- * @return string
- */
- public function getTexto()
- {
- return $this->texto;
- }
- }
- /******************************************************/
- /********************** SELECCION *********************/
- /******************************************************/
- <?php
- namespace W_Encuestas\EncuestasBundle\Entity;
- use Doctrine\ORM\Mapping as ORM;
- use Doctrine\Common\Collections\ArrayCollection;
- use Symfony\Component\Validator\Constraints as Assert;
- /**
- * @ORM\Entity
- */
- abstract class Seleccion extends Pregunta
- {
- /**
- * @ORM\Column(type="string")
- * @Assert\NotBlank(message="Debe seleccionarse una opción para 'Tipo presentación'")
- * @Assert\Choice(choices={"Horizontal", "Vertical"}, message="El valor de 'Tipo presentación' no es correcto")
- */
- protected $tipo_presentacion;
- /**
- * @ORM\Column(type="boolean")
- * @Assert\Type(type="boolean", message="El valor de 'Opciones con imágenes' no es correcto")
- */
- protected $opciones_con_imagenes;
- /**
- * @ORM\OneToMany(targetEntity="Opcion", mappedBy="seleccion")
- */
- protected $opciones;
- public function __construct()
- {
- $this->opciones = new \Doctrine\Common\Collections\ArrayCollection();
- }
- /**
- * Set tipo_presentacion
- *
- * @param string $tipoPresentacion
- */
- public function setTipoPresentacion($tipoPresentacion)
- {
- $this->tipo_presentacion = $tipoPresentacion;
- }
- /**
- * Get tipo_presentacion
- *
- * @return string
- */
- public function getTipoPresentacion()
- {
- return $this->tipo_presentacion;
- }
- /**
- * Set opciones_con_imagenes
- *
- * @param boolean $opcionesConImagenes
- */
- public function setOpcionesConImagenes($opcionesConImagenes)
- {
- $this->opciones_con_imagenes = $opcionesConImagenes;
- }
- /**
- * Get opciones_con_imagenes
- *
- * @return boolean
- */
- public function getOpcionesConImagenes()
- {
- return $this->opciones_con_imagenes;
- }
- /**
- * Add opciones
- *
- * @param W_Encuestas\EncuestasBundle\Entity\Opcion $opciones
- */
- public function addOpcion(\W_Encuestas\EncuestasBundle\Entity\Opcion $opciones)
- {
- $this->opciones[] = $opciones;
- }
- public function setOpciones(ArrayCollection $opciones)
- {
- $this->opciones = $opciones;
- }
- /**
- * Get opciones
- *
- * @return Doctrine\Common\Collections\Collection
- */
- public function getOpciones()
- {
- return $this->opciones;
- }
- }
- /******************************************************/
- /********************** SELUNICA **********************/
- /******************************************************/
- <?php
- namespace W_Encuestas\EncuestasBundle\Entity;
- use Doctrine\ORM\Mapping as ORM;
- use Doctrine\Common\Collections\ArrayCollection;
- use Symfony\Component\Validator\Constraints as Assert;
- /**
- * @ORM\Entity
- */
- class SelUnica extends Seleccion
- {
- public function __construct()
- {
- $this->opciones = new \Doctrine\Common\Collections\ArrayCollection();
- }
- /**
- * Get tipo_pregunta
- *
- * @var string
- */
- public function getTipoPregunta()
- {
- return 'SU';
- }
- }
- /******************************************************/
- /********************* SELMULTIPLE ********************/
- /******************************************************/
- <?php
- namespace W_Encuestas\EncuestasBundle\Entity;
- use Doctrine\ORM\Mapping as ORM;
- use Doctrine\Common\Collections\ArrayCollection;
- use Symfony\Component\Validator\Constraints as Assert;
- /**
- * @ORM\Entity
- */
- class SelMultiple extends Seleccion
- {
- /**
- * @ORM\Column(type="integer", nullable=true)
- * @Assert\Type(type="numeric", message="El número mínimo de respuestas tiene que ser numérico")
- */
- protected $min_respuestas;
- /**
- * @ORM\Column(type="integer", nullable=true)
- * @Assert\Type(type="numeric", message="El número máximo de respuestas tiene que ser numérico")
- */
- protected $max_respuestas;
- public function __construct()
- {
- $this->opciones = new \Doctrine\Common\Collections\ArrayCollection();
- }
- /**
- * Set min_respuestas
- *
- * @param integer $minRespuestas
- */
- public function setMinRespuestas($minRespuestas)
- {
- $this->min_respuestas = $minRespuestas;
- }
- /**
- * Get min_respuestas
- *
- * @return integer
- */
- public function getMinRespuestas()
- {
- return $this->min_respuestas;
- }
- /**
- * Set max_respuestas
- *
- * @param integer $maxRespuestas
- */
- public function setMaxRespuestas($maxRespuestas)
- {
- $this->max_respuestas = $maxRespuestas;
- }
- /**
- * Get max_respuestas
- *
- * @return integer
- */
- public function getMaxRespuestas()
- {
- return $this->max_respuestas;
- }
- /**
- * Get tipo_pregunta
- *
- * @var string
- */
- public function getTipoPregunta()
- {
- return 'SM';
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement