src/Entity/SaquitoPagina.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\SaquitoPaginaRepository;
  4. use Doctrine\Common\Collections\ArrayCollection;
  5. use Doctrine\Common\Collections\Collection;
  6. use Doctrine\ORM\Mapping as ORM;
  7. /**
  8.  * @ORM\Entity(repositoryClass=SaquitoPaginaRepository::class)
  9.  * @ORM\Table(name="saquitopaginas")
  10.  */
  11. class SaquitoPagina
  12. {
  13.     /**
  14.      * @ORM\Id
  15.      * @ORM\GeneratedValue
  16.      * @ORM\Column(type="integer")
  17.      */
  18.     private $id;
  19.     /**
  20.      * @ORM\ManyToOne(targetEntity=SaquitoPlantilla::class, inversedBy="paginas")
  21.      */
  22.     private $plantilla;
  23.     /**
  24.      * @ORM\ManyToOne(targetEntity=SaquitoMenu::class, inversedBy="paginas")
  25.      */
  26.     private $menu;
  27.     /**
  28.      * @ORM\Column(type="string", length=150)
  29.      */
  30.     private $titulo;
  31.     /**
  32.      * @ORM\Column(type="string", length=255)
  33.      */
  34.     private $slug;
  35.     /**
  36.      * @ORM\Column(type="string", length=255)
  37.      */
  38.     private $keyworks;
  39.     /**
  40.      * @ORM\Column(type="string", length=255, nullable=true)
  41.      */
  42.     private $descripcion;
  43.     /**
  44.      * @ORM\Column(type="string", length=150, nullable=true)
  45.      */
  46.     private $robots;
  47.     /**
  48.      * @ORM\Column(type="string", length=150, nullable=true)
  49.      */
  50.     private $autor;
  51.     /**
  52.      * @ORM\Column(type="string", length=10, nullable=true)
  53.      */
  54.     private $idioma;
  55.     /**
  56.      * @ORM\Column(type="date")
  57.      */
  58.     private $inicio;
  59.     /**
  60.      * @ORM\Column(type="date")
  61.      */
  62.     private $fin;
  63.     /**
  64.      * @ORM\Column(type="boolean", nullable=true)
  65.      */
  66.     private $publicar;
  67.     /**
  68.      * @ORM\Column(type="boolean", nullable=true)
  69.      */
  70.     private $privado;
  71.     /**
  72.      * @ORM\OneToMany(targetEntity=SaquitoBloque::class, mappedBy="pagina")
  73.      */
  74.     private $bloques;
  75.     public function __construct()
  76.     {
  77.         $this->bloques = new ArrayCollection();
  78.     }
  79.     public function getId(): ?int
  80.     {
  81.         return $this->id;
  82.     }
  83.     public function getPlantilla(): ?SaquitoPlantilla
  84.     {
  85.         return $this->plantilla;
  86.     }
  87.     public function setPlantilla(?SaquitoPlantilla $plantilla): self
  88.     {
  89.         $this->plantilla $plantilla;
  90.         return $this;
  91.     }
  92.     public function getMenu(): ?SaquitoMenu
  93.     {
  94.         return $this->menu;
  95.     }
  96.     public function setMenu(?SaquitoMenu $menu): self
  97.     {
  98.         $this->menu $menu;
  99.         return $this;
  100.     }
  101.     public function getTitulo(): ?string
  102.     {
  103.         return $this->titulo;
  104.     }
  105.     public function setTitulo(string $titulo): self
  106.     {
  107.         $this->titulo $titulo;
  108.         return $this;
  109.     }
  110.     public function getSlug(): ?string
  111.     {
  112.         return $this->slug;
  113.     }
  114.     public function setSlug(string $slug): self
  115.     {
  116.         $this->slug $slug;
  117.         return $this;
  118.     }
  119.     public function getKeyworks(): ?string
  120.     {
  121.         return $this->keyworks;
  122.     }
  123.     public function setKeyworks(string $keyworks): self
  124.     {
  125.         $this->keyworks $keyworks;
  126.         return $this;
  127.     }
  128.     public function getDescripcion(): ?string
  129.     {
  130.         return $this->descripcion;
  131.     }
  132.     public function setDescripcion(?string $descripcion): self
  133.     {
  134.         $this->descripcion $descripcion;
  135.         return $this;
  136.     }
  137.     public function getRobots(): ?string
  138.     {
  139.         return $this->robots;
  140.     }
  141.     public function setRobots(?string $robots): self
  142.     {
  143.         $this->robots $robots;
  144.         return $this;
  145.     }
  146.     public function getAutor(): ?string
  147.     {
  148.         return $this->autor;
  149.     }
  150.     public function setAutor(?string $autor): self
  151.     {
  152.         $this->autor $autor;
  153.         return $this;
  154.     }
  155.     public function getIdioma(): ?string
  156.     {
  157.         return $this->idioma;
  158.     }
  159.     public function setIdioma(?string $idioma): self
  160.     {
  161.         $this->idioma $idioma;
  162.         return $this;
  163.     }
  164.     public function getInicio(): ?\DateTimeInterface
  165.     {
  166.         return $this->inicio;
  167.     }
  168.     public function setInicio(\DateTimeInterface $inicio): self
  169.     {
  170.         $this->inicio $inicio;
  171.         return $this;
  172.     }
  173.     public function getFin(): ?\DateTimeInterface
  174.     {
  175.         return $this->fin;
  176.     }
  177.     public function setFin(\DateTimeInterface $fin): self
  178.     {
  179.         $this->fin $fin;
  180.         return $this;
  181.     }
  182.     public function isPublicar(): ?bool
  183.     {
  184.         return $this->publicar;
  185.     }
  186.     public function setPublicar(?bool $publicar): self
  187.     {
  188.         $this->publicar $publicar;
  189.         return $this;
  190.     }
  191.     public function isPrivado(): ?bool
  192.     {
  193.         return $this->privado;
  194.     }
  195.     public function setPrivado(?bool $privado): self
  196.     {
  197.         $this->privado $privado;
  198.         return $this;
  199.     }
  200.     /**
  201.      * Get activa
  202.      *
  203.      * @return boolean
  204.      */
  205.     public function getActiva(): ?bool
  206.     {
  207.         if ($this->isPublicar() ) {
  208.             $actual = new \DateTime("now");
  209.             if (($actual >= $this->getInicio()) && ($actual <= $this->getFin())) {
  210.                 return true;
  211.             } else {
  212.                 return false;
  213.             }
  214.         } else {
  215.             return false;
  216.         }
  217.     }
  218.     /**
  219.      * @return Collection<int, SaquitoBloque>
  220.      */
  221.     public function getBloques(): Collection
  222.     {
  223.         return $this->bloques;
  224.     }
  225.     public function addBloque(SaquitoBloque $bloque): self
  226.     {
  227.         if (!$this->bloques->contains($bloque)) {
  228.             $this->bloques[] = $bloque;
  229.             $bloque->setPagina($this);
  230.         }
  231.         return $this;
  232.     }
  233.     public function removeBloque(SaquitoBloque $bloque): self
  234.     {
  235.         if ($this->bloques->removeElement($bloque)) {
  236.             // set the owning side to null (unless already changed)
  237.             if ($bloque->getPagina() === $this) {
  238.                 $bloque->setPagina(null);
  239.             }
  240.         }
  241.         return $this;
  242.     }    
  243.     public function __toString()
  244.     {
  245.         return $this->titulo;
  246.     }        
  247. }