src/SettingsBundle/Entity/Setting.php line 31

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. /*
  4.  * This file is part of SolidInvoice project.
  5.  *
  6.  * (c) Pierre du Plessis <open-source@solidworx.co>
  7.  *
  8.  * This source file is subject to the MIT license that is bundled
  9.  * with this source code in the file LICENSE.
  10.  */
  11. namespace SolidInvoice\SettingsBundle\Entity;
  12. use Doctrine\DBAL\Types\Types;
  13. use Doctrine\ORM\Mapping as ORM;
  14. use Ramsey\Uuid\Doctrine\UuidBinaryOrderedTimeType;
  15. use Ramsey\Uuid\Doctrine\UuidOrderedTimeGenerator;
  16. use Ramsey\Uuid\UuidInterface;
  17. use Serializable;
  18. use SolidInvoice\CoreBundle\Traits\Entity\CompanyAware;
  19. use SolidInvoice\SettingsBundle\Repository\SettingsRepository;
  20. use Stringable;
  21. use Symfony\Bridge\Doctrine\Validator\Constraints\UniqueEntity;
  22. #[ORM\Table(nameSetting::TABLE_NAME)]
  23. #[ORM\UniqueConstraint(columns: ['setting_key''company_id'])]
  24. #[ORM\Entity(repositoryClassSettingsRepository::class)]
  25. #[UniqueEntity(fields: ['company_id''key'])]
  26. class Setting implements StringableSerializable
  27. {
  28.     final public const TABLE_NAME 'app_config';
  29.     use CompanyAware;
  30.     #[ORM\Column(name'id'typeUuidBinaryOrderedTimeType::NAME)]
  31.     #[ORM\Id]
  32.     #[ORM\GeneratedValue(strategy'CUSTOM')]
  33.     #[ORM\CustomIdGenerator(class: UuidOrderedTimeGenerator::class)]
  34.     private ?UuidInterface $id null;
  35.     #[ORM\Column(name'setting_key'typeTypes::STRINGlength125)]
  36.     protected ?string $key null;
  37.     #[ORM\Column(name'setting_value'typeTypes::TEXTnullabletrue)]
  38.     protected ?string $value null;
  39.     #[ORM\Column(name'description'typeTypes::TEXTnullabletrue)]
  40.     protected ?string $description null;
  41.     #[ORM\Column(name'field_type'typeTypes::STRING)]
  42.     protected ?string $type null;
  43.     public function getId(): ?UuidInterface
  44.     {
  45.         return $this->id;
  46.     }
  47.     public function getKey(): string
  48.     {
  49.         return $this->key;
  50.     }
  51.     public function setKey(string $key): self
  52.     {
  53.         $this->key $key;
  54.         return $this;
  55.     }
  56.     public function getValue(): ?string
  57.     {
  58.         return $this->value;
  59.     }
  60.     public function setValue(mixed $value): self
  61.     {
  62.         $this->value $value;
  63.         return $this;
  64.     }
  65.     public function getDescription(): ?string
  66.     {
  67.         return $this->description;
  68.     }
  69.     public function setDescription(?string $description): self
  70.     {
  71.         $this->description $description;
  72.         return $this;
  73.     }
  74.     public function getType(): ?string
  75.     {
  76.         return $this->type;
  77.     }
  78.     public function setType(string $type): self
  79.     {
  80.         $this->type $type;
  81.         return $this;
  82.     }
  83.     public function __toString(): string
  84.     {
  85.         return (string) $this->value;
  86.     }
  87.     public function __serialize(): array
  88.     {
  89.         return [
  90.             $this->id,
  91.             $this->key,
  92.             $this->value,
  93.             $this->description,
  94.             $this->type,
  95.         ];
  96.     }
  97.     /**
  98.      * @param array{0: UuidInterface|null, 1: string|null, 2: string|null, 3: string|null, 4: string|null} $data
  99.      */
  100.     public function __unserialize(array $data): void
  101.     {
  102.         [
  103.             $this->id,
  104.             $this->key,
  105.             $this->value,
  106.             $this->description,
  107.             $this->type,
  108.         ] = $data;
  109.     }
  110.     public function serialize(): string
  111.     {
  112.         return serialize($this->__serialize());
  113.     }
  114.     public function unserialize(string $data): void
  115.     {
  116.         $this->__unserialize(unserialize($data));
  117.     }
  118. }