src/Entity/Bloc.php line 10

Open in your IDE?
  1. <?php
  2. namespace App\Entity;
  3. use App\Repository\BlocRepository;
  4. use Doctrine\DBAL\Types\Types;
  5. use Doctrine\ORM\Mapping as ORM;
  6. #[ORM\Entity(repositoryClassBlocRepository::class)]
  7. class Bloc
  8. {
  9.     #[ORM\Id]
  10.     #[ORM\GeneratedValue]
  11.     #[ORM\Column]
  12.     private ?int $id null;
  13.     #[ORM\Column(nullabletrue)]
  14.     private ?int $ordre null;
  15.     #[ORM\Column(typeTypes::TEXTnullabletrue)]
  16.     private ?string $description null;
  17.     #[ORM\Column(length255nullabletrue)]
  18.     private ?string $titre null;
  19.     #[ORM\Column(length255nullabletrue)]
  20.     private ?string $emplacement null;
  21.     #[ORM\Column(length255nullabletrue)]
  22.     private ?string $type null;
  23.     #[ORM\Column(type'boolean'options: ["default" => true])]
  24.     private ?bool $actif true;
  25.     #[ORM\Column(length255nullabletrue)]
  26.     private ?string $config null;
  27.     #[ORM\ManyToOne(inversedBy'bloc')]
  28.     private ?Section $section null;
  29.     public function __construct()
  30.     {
  31.     }
  32.     public function getId(): ?int
  33.     {
  34.         return $this->id;
  35.     }
  36.     public function getOrdre(): ?int
  37.     {
  38.         return $this->ordre;
  39.     }
  40.     public function setOrdre(?int $ordre): static
  41.     {
  42.         $this->ordre $ordre;
  43.         return $this;
  44.     }
  45.     public function getDescription(): ?string
  46.     {
  47.         return $this->description;
  48.     }
  49.     public function setDescription(?string $description): static
  50.     {
  51.         $this->description $description;
  52.         return $this;
  53.     }
  54.     public function getTitre(): ?string
  55.     {
  56.         return $this->titre;
  57.     }
  58.     public function setTitre(?string $titre): static
  59.     {
  60.         $this->titre $titre;
  61.         return $this;
  62.     }
  63.     public function getEmplacement(): ?string
  64.     {
  65.         return $this->emplacement;
  66.     }
  67.     public function setEmplacement(?string $emplacement): static
  68.     {
  69.         $this->emplacement $emplacement;
  70.         return $this;
  71.     }
  72.     public function getDocument(): ?Document
  73.     {
  74.         return $this->section $this->section->getDocument() : null;
  75.     }
  76.     public function getType(): ?string
  77.     {
  78.         return $this->type;
  79.     }
  80.     public function setType(?string $type): static
  81.     {
  82.         $this->type $type;
  83.         return $this;
  84.     }
  85.     public function isActif(): ?bool
  86.     {
  87.         return $this->actif;
  88.     }
  89.     public function setActif(?bool $actif): static
  90.     {
  91.         $this->actif $actif;
  92.         return $this;
  93.     }
  94.     public function getConfig(): ?string
  95.     {
  96.         return $this->config;
  97.     }
  98.     public function getDecodedConfig(): array
  99.     {
  100.         return $this->decodeConfig();
  101.     }
  102.     public function getWidth(): ?string
  103.     {
  104.         $config $this->decodeConfig();
  105.         return $config['width'] ?? null// Return width if it exists, otherwise null
  106.     }
  107.     public function getHeight(): ?string
  108.     {
  109.         $config $this->decodeConfig();
  110.         return $config['height'] ?? null// Return height if it exists, otherwise null
  111.     }
  112.     public function getAlign(): ?string
  113.     {
  114.         $config $this->decodeConfig();
  115.         return $config['align'] ?? null// Return align if it exists, otherwise null
  116.     }
  117.     private function decodeConfig(): array
  118.     {
  119.         if ($this->config === null) {
  120.             return [];
  121.         }
  122.         // Decode the JSON string, return empty array on failure
  123.         $decoded json_decode($this->configtrue);
  124.         return is_array($decoded) ? $decoded : [];
  125.     }
  126.     public function setConfig(?string $config): static
  127.     {
  128.         $this->config $config;
  129.         return $this;
  130.     }
  131.     public function getSection(): ?Section
  132.     {
  133.         return $this->section;
  134.     }
  135.     public function setSection(?Section $section): static
  136.     {
  137.         $this->section $section;
  138.         return $this;
  139.     }
  140. }