src/Flexy/FrontBundle/Entity/Bloc.php line 13
<?php
namespace App\Flexy\FrontBundle\Entity;
use ApiPlatform\Core\Annotation\ApiResource;
use App\Flexy\FrontBundle\Repository\BlocRepository;
use Gedmo\Mapping\Annotation as Gedmo;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ApiResource]
#[ORM\Entity(repositoryClass: BlocRepository::class)]
class Bloc
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column(type: 'integer')]
private $id;
#[ORM\Column(type: 'string', length: 255)]
private $title;
#[ORM\Column(type: 'text', nullable: true)]
private ?string $content = null;
#[ORM\Column(type: 'json', nullable: true)]
private $jsonContent=[];
#[ORM\Column(type: 'json', nullable: true)]
private $jsonSimplifiedContent;
#[ORM\Column(type: 'datetime', nullable: true)]
private ?\DateTimeInterface $createdAt = null;
/**
* @Gedmo\Slug(fields={"title"})
*/
#[Gedmo\Slug(fields: ['title'])]
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private ?string $slug = null;
#[ORM\Column(type: 'boolean', nullable: true)]
private ?bool $isEnabled = null;
#[ORM\Column(type: 'boolean', nullable: true)]
private $isLiveEditor;
#[ORM\Column(type: 'string', length: 255, nullable: true)]
private $pageEditor="summernote";
public function getId(): ?int
{
return $this->id;
}
public function getContent(): ?string
{
return $this->content;
}
public function setContent(?string $content): self
{
$this->content = $content;
return $this;
}
public function getCreatedAt(): ?\DateTimeInterface
{
return $this->createdAt;
}
public function setCreatedAt(?\DateTimeInterface $createdAt): self
{
$this->createdAt = $createdAt;
return $this;
}
public function getSlug(): ?string
{
return $this->slug;
}
public function setSlug(string $slug): self
{
$this->slug = $slug;
return $this;
}
public function getIsEnabled(): ?bool
{
return $this->isEnabled;
}
public function setIsEnabled(?bool $isEnabled): self
{
$this->isEnabled = $isEnabled;
return $this;
}
/**
* Get the value of title
*/
public function getTitle()
{
return $this->title;
}
/**
* Set the value of title
*
* @return self
*/
public function setTitle($title)
{
$this->title = $title;
return $this;
}
/**
* Get the value of jsonContent
*/
public function getJsonContent()
{
if($this->jsonContent==null){
return [];
}
return $this->jsonContent;
}
/**
* Set the value of jsonContent
*
* @return self
*/
public function setJsonContent($jsonContent)
{
$this->jsonContent = $jsonContent;
return $this;
}
public function jsonContentCSS() {
$contents = $this->jsonSimplifiedContent;
$css = '';
//dd($this->jsonContent);
foreach ($contents as $singleContent) {
$css = $css.$singleContent["css"];
}
return $css;
}
public function jsonContentHTML() {
$contents = $this->jsonSimplifiedContent;
$html = '';
//dd($this->jsonContent);
foreach ($contents as $singleContent) {
$html = $html.$singleContent["html"];
}
return $html;
}
public function jsonContentToHtml() {
$obj = $this->jsonContent;
$html = '';
//dd($this->jsonContent);
foreach ($obj["blocks"] as $block) {
switch ($block["type"]) {
case 'paragraph':
$html .= '<p>' . $block["data"]["text"] . '</p>';
break;
case 'header':
$html .= '<h'. $block["data"]["level"] .'>' . $block["data"]["text"] . '</h'. $block["data"]["level"] .'>';
break;
case 'raw':
$html .= $block["data"]["html"];
break;
case 'list':
$lsType = ($block["data"]["style"] == 'ordered') ? 'ol' : 'ul';
$html .= '<' . $lsType . '>';
foreach($block["data"]["items"] as $item) {
$html .= '<li>' . $item . '</li>';
}
$html .= '</' . $lsType . '>';
break;
case 'code':
$html .= '<pre><code class="language-'. $block["data"]["lang"] .'">'. $block["data"]["code"] .'</code></pre>';
break;
case 'image':
$html .= '<div class="img_pnl"><img src="'. $block["data"]["file"]["url"]->url .'" /></div>';
break;
default:
break;
}
}
return $html;
}
/**
* Get the value of isLiveEditor
*/
public function getIsLiveEditor()
{
return $this->isLiveEditor;
}
/**
* Set the value of isLiveEditor
*
* @return self
*/
public function setIsLiveEditor($isLiveEditor)
{
$this->isLiveEditor = $isLiveEditor;
return $this;
}
/**
* Get the value of pageEditor
*/
public function getPageEditor()
{
return $this->pageEditor;
}
/**
* Set the value of pageEditor
*
* @return self
*/
public function setPageEditor($pageEditor)
{
$this->pageEditor = $pageEditor;
return $this;
}
/**
* Get the value of jsonSimplifiedContent
*/
public function getJsonSimplifiedContent()
{
return $this->jsonSimplifiedContent;
}
/**
* Set the value of jsonSimplifiedContent
*
* @return self
*/
public function setJsonSimplifiedContent($jsonSimplifiedContent)
{
$this->jsonSimplifiedContent = $jsonSimplifiedContent;
return $this;
}
}