<?php
namespace App\Entity;
use Symfony\Component\Serializer\Annotation\Groups;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Entity(repositoryClass="App\Repository\OmeloPageRepository")
*/
class OmeloPage
{
/**
* @ORM\Id()
* @ORM\GeneratedValue()
* @ORM\Column(type="integer")
*/
private $id;
/**
* @ORM\Column(type="string", length=255)
*/
private $url;
/**
* @ORM\Column(type="string", length=5)
*/
private $lang;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $javascript;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $stylesheet;
/**
* @ORM\Column(type="string", length=255, nullable=true)
*/
private $template;
/**
* @ORM\Column(type="text", nullable=true)
*/
private $content;
/**
* @ORM\Column(type="string", length=1, nullable=true)
* not used fix a bug in admin
*/
private $mainContent;
/**
* @ORM\Column(type="string", length=100, nullable=true)
*/
private $metaTitle;
/**
* @ORM\Column(type="string", length=200, nullable=true)
*/
private $metaDescription;
public function getId(): ?int
{
return $this->id;
}
public function getUrl(): ?string
{
return $this->url;
}
public function setUrl(string $url): self
{
$this->url = $url;
return $this;
}
public function getLang(): ?string
{
return $this->lang;
}
public function setLang(string $lang): self
{
$this->lang = $lang;
return $this;
}
public function getLayers(): ?string
{
$content = $this->getContentInJson();
if(!empty($content['panelList']))
return $content['panelList'];
else
return '';
}
public function setLayers($layers): self
{
return $this;
}
public function getMainContent(): ?string
{
$content = $this->getContentInJson();
if(isset($content['custom']) && !empty(trim($content['custom']))){
return $content['custom'];
}elseif (isset($content['mainContent']))
return $content['mainContent'];
else
return '';
}
public function setMainContent(?string $mainContent): self
{
$content = $this->getContentInJson();
$content['custom'] = $mainContent;
$this->setContent(json_encode($content, true));
return $this;
}
public function getJavascript(): ?string
{
return $this->javascript;
}
public function setJavascript(?string $javascript): self
{
$this->javascript = $javascript;
return $this;
}
public function getStylesheet(): ?string
{
return $this->stylesheet;
}
public function setStylesheet(?string $stylesheet): self
{
$this->stylesheet = $stylesheet;
return $this;
}
public function getTemplate(): ?string
{
return $this->template;
}
public function setTemplate(?string $template): self
{
$this->template = $template;
return $this;
}
public function getContent()
{
return $this->content;
}
public function getContentInJson(){
if(!empty($this->getContent())){
//Let's replace all images by optimized one
$json = trim(trim($this->getContent(), '"'), "'");
$contents = json_decode($json, true);
return $contents;
}
}
public function setContent($content): self
{
$this->content = $content;
return $this;
}
public function getMetaTitle(): ?string
{
return $this->metaTitle;
}
public function setMetaTitle(?string $metaTitle): self
{
$this->metaTitle = $metaTitle;
return $this;
}
public function getMetaDescription(): ?string
{
return $this->metaDescription;
}
public function setMetaDescription($metaDescription): self
{
$this->metaDescription = $metaDescription;
return $this;
}
public function __toString(){
return 'Page '.$this->url;
}
}