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.     #[ORM\ManyToOne(targetEntityDocument::class, inversedBy'directBlocs')]
  30.     #[ORM\JoinColumn(nullabletrueonDelete'CASCADE')]
  31.     private ?Document $document null;
  32.     public function __construct()
  33.     {
  34.     }
  35.     public function getId(): ?int
  36.     {
  37.         return $this->id;
  38.     }
  39.     public function getOrdre(): ?int
  40.     {
  41.         return $this->ordre;
  42.     }
  43.     public function setOrdre(?int $ordre): static
  44.     {
  45.         $this->ordre $ordre;
  46.         return $this;
  47.     }
  48.     public function getDescription(): ?string
  49.     {
  50.         return $this->description;
  51.     }
  52.     public function setDescription(?string $description): static
  53.     {
  54.         $this->description $description;
  55.         return $this;
  56.     }
  57.     public function getTitre(): ?string
  58.     {
  59.         return $this->titre;
  60.     }
  61.     public function setTitre(?string $titre): static
  62.     {
  63.         $this->titre $titre;
  64.         return $this;
  65.     }
  66.     public function getEmplacement(): ?string
  67.     {
  68.         return $this->emplacement;
  69.     }
  70.     public function setEmplacement(?string $emplacement): static
  71.     {
  72.         $this->emplacement $emplacement;
  73.         return $this;
  74.     }
  75.     public function getDocument(): ?Document
  76.     {
  77.         return $this->document ?? ($this->section?->getDocument());
  78.     }
  79.     public function setDocument(?Document $document): static
  80.     {
  81.         $this->document $document;
  82.         return $this;
  83.     }
  84.     public function getType(): ?string
  85.     {
  86.         return $this->type;
  87.     }
  88.     public function setType(?string $type): static
  89.     {
  90.         $this->type $type;
  91.         return $this;
  92.     }
  93.     public function isActif(): ?bool
  94.     {
  95.         return $this->actif;
  96.     }
  97.     public function setActif(?bool $actif): static
  98.     {
  99.         $this->actif $actif;
  100.         return $this;
  101.     }
  102.     public function getConfig(): ?string
  103.     {
  104.         return $this->config;
  105.     }
  106.     public function getDecodedConfig(): array
  107.     {
  108.         return $this->decodeConfig();
  109.     }
  110.     public function getWidth(): ?string
  111.     {
  112.         $config $this->decodeConfig();
  113.         return $config['width'] ?? null// Return width if it exists, otherwise null
  114.     }
  115.     public function getHeight(): ?string
  116.     {
  117.         $config $this->decodeConfig();
  118.         return $config['height'] ?? null// Return height if it exists, otherwise null
  119.     }
  120.     public function getAlign(): ?string
  121.     {
  122.         $config $this->decodeConfig();
  123.         return $config['align'] ?? null// Return align if it exists, otherwise null
  124.     }
  125.     private function decodeConfig(): array
  126.     {
  127.         if ($this->config === null) {
  128.             return [];
  129.         }
  130.         // Decode the JSON string, return empty array on failure
  131.         $decoded json_decode($this->configtrue);
  132.         return is_array($decoded) ? $decoded : [];
  133.     }
  134.     public function setConfig(?string $config): static
  135.     {
  136.         $this->config $config;
  137.         return $this;
  138.     }
  139.     public function getSection(): ?Section
  140.     {
  141.         return $this->section;
  142.     }
  143.     public function setSection(?Section $section): static
  144.     {
  145.         $this->section $section;
  146.         return $this;
  147.     }
  148. }