<?php
namespace App\Entity;
use App\Repository\SaquitoPaginaRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass=SaquitoPaginaRepository::class)
* @ORM\Table(name="saquitopaginas")
*/
class SaquitoPagina
{
/**
* @ORM\Id
* @ORM\GeneratedValue
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\ManyToOne(targetEntity=SaquitoPlantilla::class, inversedBy="paginas")
*/
private $plantilla;
/**
* @ORM\ManyToOne(targetEntity=SaquitoMenu::class, inversedBy="paginas")
*/
private $menu;
/**
* @ORM\Column(type="string", length=150)
*/
private $titulo;
/**
* @ORM\Column(type="string", length=255)
*/
private $slug;
/**
* @ORM\Column(type="string", length=255)
*/
private $keyworks;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $descripcion;
/**
* @ORM\Column(type="string", length=150, nullable=true)
*/
private $robots;
/**
* @ORM\Column(type="string", length=150, nullable=true)
*/
private $autor;
/**
* @ORM\Column(type="string", length=10, nullable=true)
*/
private $idioma;
/**
* @ORM\Column(type="date")
*/
private $inicio;
/**
* @ORM\Column(type="date")
*/
private $fin;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $publicar;
/**
* @ORM\Column(type="boolean", nullable=true)
*/
private $privado;
/**
* @ORM\OneToMany(targetEntity=SaquitoBloque::class, mappedBy="pagina")
*/
private $bloques;
public function __construct()
{
$this->bloques = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getPlantilla(): ?SaquitoPlantilla
{
return $this->plantilla;
}
public function setPlantilla(?SaquitoPlantilla $plantilla): self
{
$this->plantilla = $plantilla;
return $this;
}
public function getMenu(): ?SaquitoMenu
{
return $this->menu;
}
public function setMenu(?SaquitoMenu $menu): self
{
$this->menu = $menu;
return $this;
}
public function getTitulo(): ?string
{
return $this->titulo;
}
public function setTitulo(string $titulo): self
{
$this->titulo = $titulo;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
public function getKeyworks(): ?string
{
return $this->keyworks;
}
public function setKeyworks(string $keyworks): self
{
$this->keyworks = $keyworks;
return $this;
}
public function getDescripcion(): ?string
{
return $this->descripcion;
}
public function setDescripcion(?string $descripcion): self
{
$this->descripcion = $descripcion;
return $this;
}
public function getRobots(): ?string
{
return $this->robots;
}
public function setRobots(?string $robots): self
{
$this->robots = $robots;
return $this;
}
public function getAutor(): ?string
{
return $this->autor;
}
public function setAutor(?string $autor): self
{
$this->autor = $autor;
return $this;
}
public function getIdioma(): ?string
{
return $this->idioma;
}
public function setIdioma(?string $idioma): self
{
$this->idioma = $idioma;
return $this;
}
public function getInicio(): ?\DateTimeInterface
{
return $this->inicio;
}
public function setInicio(\DateTimeInterface $inicio): self
{
$this->inicio = $inicio;
return $this;
}
public function getFin(): ?\DateTimeInterface
{
return $this->fin;
}
public function setFin(\DateTimeInterface $fin): self
{
$this->fin = $fin;
return $this;
}
public function isPublicar(): ?bool
{
return $this->publicar;
}
public function setPublicar(?bool $publicar): self
{
$this->publicar = $publicar;
return $this;
}
public function isPrivado(): ?bool
{
return $this->privado;
}
public function setPrivado(?bool $privado): self
{
$this->privado = $privado;
return $this;
}
/**
* Get activa
*
* @return boolean
*/
public function getActiva(): ?bool
{
if ($this->isPublicar() ) {
$actual = new \DateTime("now");
if (($actual >= $this->getInicio()) && ($actual <= $this->getFin())) {
return true;
} else {
return false;
}
} else {
return false;
}
}
/**
* @return Collection<int, SaquitoBloque>
*/
public function getBloques(): Collection
{
return $this->bloques;
}
public function addBloque(SaquitoBloque $bloque): self
{
if (!$this->bloques->contains($bloque)) {
$this->bloques[] = $bloque;
$bloque->setPagina($this);
}
return $this;
}
public function removeBloque(SaquitoBloque $bloque): self
{
if ($this->bloques->removeElement($bloque)) {
// set the owning side to null (unless already changed)
if ($bloque->getPagina() === $this) {
$bloque->setPagina(null);
}
}
return $this;
}
public function __toString()
{
return $this->titulo;
}
}