src/Entity/BannerItem.php line 21

  1. <?php
  2. namespace App\Entity;
  3. use Gedmo\Mapping\Annotation as Gedmo;
  4. use Doctrine\ORM\Mapping as ORM;
  5. use Doctrine\Common\Collections\ArrayCollection;
  6. use App\Entity\Banner;
  7. use A2lix\TranslationFormBundle\Util\Knp\KnpTranslatable;
  8. use Knp\DoctrineBehaviors\Contract\Entity\TranslatableInterface;
  9. use Knp\DoctrineBehaviors\Model\Translatable\TranslatableTrait;
  10. /**
  11.  * BannerItem
  12.  *
  13.  * @ORM\Table(name="banner_item")
  14.  * @ORM\Entity
  15.  */
  16. class BannerItem implements TranslatableInterface
  17. {
  18.     /* Begin Translatable */
  19.     
  20.     use TranslatableTrait;
  21.     
  22.     public function __call($method$arguments)
  23.     {
  24.         return $this->proxyCurrentLocaleTranslation($method$arguments);
  25.     }
  26.     /* End Translatable */
  27.        
  28.     
  29.     /**
  30.      * @var string
  31.      *
  32.      * @ORM\Column(name="id", type="integer")      
  33.      * @ORM\Id
  34.      * @ORM\GeneratedValue
  35.      */
  36.     private $id;
  37.     /**
  38.      * @var \DateTime
  39.      *
  40.      * @ORM\Column(name="fecha_inicio", type="datetime")
  41.      */
  42.     private $fechaInicio;    
  43.     
  44.     /**
  45.      * @var \DateTime
  46.      *
  47.      * @ORM\Column(name="fecha_fin", type="datetime")
  48.      */
  49.     private $fechaFin;        
  50.    
  51.     /**
  52.      * @ORM\ManyToOne(targetEntity="Banner", inversedBy="items", cascade={"persist"})
  53.      * @ORM\JoinColumn(name="banner_id", referencedColumnName="id"))
  54.      * @Gedmo\SortableGroup    
  55.      */
  56.     private $banner;
  57.     
  58.     
  59.     /**
  60.      * @var string
  61.      *
  62.      * @ORM\Column(name="target", type="string", length=20, options={"default":"_blank"})
  63.      */
  64.     private $target;       
  65.     
  66.     
  67.    
  68.     /**
  69.      * @Gedmo\SortablePosition
  70.      * @ORM\Column(name="position", type="integer")
  71.      */
  72.     private $position;    
  73.         
  74.     
  75.     /**
  76.      * @var Array
  77.      *
  78.      * @ORM\Column(name="locales", type="array")
  79.      */
  80.     protected $locales;      
  81.         
  82.     public function __construct()
  83.     {
  84.         $this->fechaInicio = new \DateTime();
  85.         $this->fechaFin = new \DateTime();
  86.         $this->fechaFin->modify("+1 year");
  87.         $this->locales = array("es","en","fr");
  88.         $this->target "_self";
  89.     }
  90.     
  91.     
  92.     public function __toString()
  93.     {
  94.         $banner $this->getBanner();
  95.         if (isset($banner))
  96.             return $this->getBanner()->getNombre().": ".$this->getTitulo();
  97.         elseif ($this->getTitulo())
  98.             return $this->getTitulo();
  99.         else
  100.             return "na";
  101.     }
  102.     
  103.     /**
  104.      * Set id
  105.      *
  106.      * @param string $id
  107.      * @return Pais
  108.      */
  109.     public function setId($id)
  110.     {
  111.         $this->id $id;
  112.     
  113.         return $this;
  114.     }    
  115.     
  116.     /**
  117.      * Get id
  118.      *
  119.      * @return string 
  120.      */
  121.     public function getId()
  122.     {
  123.         return $this->id;
  124.     }
  125.     
  126.     /**
  127.      * Set activo
  128.      *
  129.      * @param boolean $activo
  130.      * @return Pais
  131.      */
  132.     public function setActivo($activo)
  133.     {
  134.         $this->activo $activo;
  135.     
  136.         return $this;
  137.     }
  138.     /**
  139.      * Get activo
  140.      *
  141.      * @return boolean 
  142.      */
  143.     public function getActivo()
  144.     {
  145.         return $this->activo;
  146.     }    
  147.     
  148.     /**
  149.      * Set banner
  150.      *
  151.      * @param Banner $banner
  152.      * @return BannerItem
  153.      */
  154.     public function setBanner(Banner $banner)
  155.     {
  156.         $this->banner $banner;
  157.     
  158.         return $this;
  159.     }
  160.     /**
  161.      * Get banner
  162.      *
  163.      * @return Banner 
  164.      */
  165.     public function getBanner()
  166.     {
  167.         return $this->banner;
  168.     }    
  169.     
  170.     
  171.     /**
  172.      * Set fechaInicio
  173.      *
  174.      * @param DateTime $fechainicio
  175.      * @return BannerItem
  176.      */
  177.     public function setFechaInicio(\DateTime $fechainicio)
  178.     {
  179.         $this->fechaInicio $fechainicio;
  180.     
  181.         return $this;
  182.     }
  183.     /**
  184.      * Get fechaInicio
  185.      *
  186.      * @return fechaInicio 
  187.      */
  188.     public function getFechaInicio()
  189.     {
  190.         return $this->fechaInicio;
  191.     }      
  192.     
  193.     /**
  194.      * Set fechaFin
  195.      *
  196.      * @param DateTime $fechafin
  197.      * @return BannerItem
  198.      */
  199.     public function setFechaFin(\DateTime $fechafin)
  200.     {
  201.         $this->fechaFin $fechafin;
  202.     
  203.         return $this;
  204.     }
  205.     /**
  206.      * Get fechaFin
  207.      *
  208.      * @return fechaFin 
  209.      */
  210.     public function getFechaFin()
  211.     {
  212.         return $this->fechaFin;
  213.     }     
  214.     
  215.     
  216.         
  217.     /**
  218.      * Set target
  219.      *
  220.      * @param string $target
  221.      * @return BannerItem
  222.      */
  223.     public function setTarget($target)
  224.     {
  225.         $this->target $target;
  226.     
  227.         return $this;
  228.     }
  229.     /**
  230.      * Get target
  231.      *
  232.      * @return string 
  233.      */
  234.     public function getTarget()
  235.     {
  236.         return $this->target;
  237.     } 
  238.     
  239.   
  240.     
  241.  
  242.     
  243.     /**
  244.      * Set locales
  245.      *
  246.      * @param array $locales
  247.      * @return BannerItem
  248.      */
  249.     public function setLocales($locales)
  250.     {
  251.         $this->locales $locales;
  252.     
  253.         return $this;
  254.     }
  255.     /**
  256.      * Get locales
  257.      *
  258.      * @return array 
  259.      */
  260.     public function getLocales()
  261.     {
  262.         return $this->locales;
  263.     }     
  264.     
  265.     
  266.     public function setPosition($position)
  267.     {
  268.         $this->position $position;
  269.         
  270.         return $this;
  271.     }
  272.     public function getPosition()
  273.     {
  274.         return $this->position;
  275.     }   
  276.     
  277. }