<?php
namespace App\Entity;
use App\Repository\BlocRepository;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\Common\Collections\Collection;
use Doctrine\DBAL\Types\Types;
use Doctrine\ORM\Mapping as ORM;
#[ORM\Entity(repositoryClass: BlocRepository::class)]
class Bloc
{
#[ORM\Id]
#[ORM\GeneratedValue]
#[ORM\Column]
private ?int $id = null;
#[ORM\Column(nullable: true)]
private ?int $ordre = null;
#[ORM\Column(type: Types::TEXT, nullable: true)]
private ?string $description = null;
#[ORM\Column(nullable: true)]
private ?array $columns = null;
#[ORM\Column(nullable: true)]
private ?array $rowData = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $nom = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $imageFiles = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $titre = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $descriptionimage = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $emplacement = null;
#[ORM\ManyToOne(inversedBy: 'blocs')]
private ?Document $document = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $type = null;
#[ORM\ManyToOne(targetEntity: self::class, inversedBy: 'blocsection')]
private ?self $bloc = null;
#[ORM\OneToMany(mappedBy: 'bloc', targetEntity: self::class)]
private Collection $blocsection;
#[ORM\Column(nullable: true)]
private ?bool $actif = null;
#[ORM\Column(length: 255, nullable: true)]
private ?string $config = null;
#[ORM\ManyToOne(inversedBy: 'bloc')]
private ?Section $section = null;
public function __construct()
{
$this->blocsection = new ArrayCollection();
}
public function getId(): ?int
{
return $this->id;
}
public function getOrdre(): ?int
{
return $this->ordre;
}
public function setOrdre(?int $ordre): static
{
$this->ordre = $ordre;
return $this;
}
public function getDescription(): ?string
{
return $this->description;
}
public function setDescription(?string $description): static
{
$this->description = $description;
return $this;
}
public function getColumns(): ?array
{
return $this->columns;
}
public function setColumns(?array $columns): static
{
$this->columns = $columns;
return $this;
}
public function getRowData(): ?array
{
return $this->rowData;
}
public function setRowData(?array $rowData): static
{
$this->rowData = $rowData;
return $this;
}
public function getNom(): ?string
{
return $this->nom;
}
public function setNom(?string $nom): static
{
$this->nom = $nom;
return $this;
}
public function getImageFiles(): ?string
{
return $this->imageFiles;
}
public function setImageFiles(?string $imageFiles): static
{
$this->imageFiles = $imageFiles;
return $this;
}
public function getTitre(): ?string
{
return $this->titre;
}
public function setTitre(?string $titre): static
{
$this->titre = $titre;
return $this;
}
public function getDescriptionimage(): ?string
{
return $this->descriptionimage;
}
public function setDescriptionimage(?string $descriptionimage): static
{
$this->descriptionimage = $descriptionimage;
return $this;
}
public function getEmplacement(): ?string
{
return $this->emplacement;
}
public function setEmplacement(?string $emplacement): static
{
$this->emplacement = $emplacement;
return $this;
}
public function getDocument(): ?Document
{
return $this->document;
}
public function setDocument(?Document $document): static
{
$this->document = $document;
return $this;
}
public function getType(): ?string
{
return $this->type;
}
public function setType(?string $type): static
{
$this->type = $type;
return $this;
}
public function getBloc(): ?self
{
return $this->bloc;
}
public function setBloc(?self $bloc): static
{
$this->bloc = $bloc;
return $this;
}
/**
* @return Collection<int, self>
*/
public function getBlocsection(): Collection
{
return $this->blocsection;
}
public function addBlocsection(self $blocsection): static
{
if (!$this->blocsection->contains($blocsection)) {
$this->blocsection->add($blocsection);
$blocsection->setBloc($this);
}
return $this;
}
public function removeBlocsection(self $blocsection): static
{
if ($this->blocsection->removeElement($blocsection)) {
// set the owning side to null (unless already changed)
if ($blocsection->getBloc() === $this) {
$blocsection->setBloc(null);
}
}
return $this;
}
public function isActif(): ?bool
{
return $this->actif;
}
public function setActif(?bool $actif): static
{
$this->actif = $actif;
return $this;
}
public function getConfig(): ?string
{
return $this->config;
}
public function getDecodedConfig(): array
{
return $this->decodeConfig();
}
public function getWidth(): ?string
{
$config = $this->decodeConfig();
return $config['width'] ?? null; // Return width if it exists, otherwise null
}
public function getHeight(): ?string
{
$config = $this->decodeConfig();
return $config['height'] ?? null; // Return height if it exists, otherwise null
}
public function getAlign(): ?string
{
$config = $this->decodeConfig();
return $config['align'] ?? null; // Return align if it exists, otherwise null
}
private function decodeConfig(): array
{
if ($this->config === null) {
return [];
}
// Decode the JSON string, return empty array on failure
$decoded = json_decode($this->config, true);
return is_array($decoded) ? $decoded : [];
}
public function setConfig(?string $config): static
{
$this->config = $config;
return $this;
}
public function getSection(): ?Section
{
return $this->section;
}
public function setSection(?Section $section): static
{
$this->section = $section;
return $this;
}
}