src/Shop/Doctrine/Entity/FeatureValue.php line 22

Open in your IDE?
  1. <?php
  2. declare(strict_types=1);
  3. namespace App\Shop\Doctrine\Entity;
  4. use App\Shop\Doctrine\EntityListener\FeatureValueListener;
  5. use DateTimeImmutable;
  6. use Doctrine\ORM\Mapping\Column;
  7. use Doctrine\ORM\Mapping\Entity;
  8. use Doctrine\ORM\Mapping\EntityListeners;
  9. use Doctrine\ORM\Mapping\GeneratedValue;
  10. use Doctrine\ORM\Mapping\Id;
  11. use Doctrine\ORM\Mapping\JoinColumn;
  12. use Doctrine\ORM\Mapping\ManyToOne;
  13. use Doctrine\ORM\Mapping\Table;
  14. use Symfony\Component\Serializer\Annotation\Groups;
  15. #[Entity]
  16. #[EntityListeners([FeatureValueListener::class])]
  17. #[Table(name'`shop_feature_value`')]
  18. class FeatureValue
  19. {
  20.     #[Id]
  21.     #[Column(type'integer')]
  22.     #[GeneratedValue]
  23.     #[Groups(['product'])]
  24.     private ?int $id null;
  25.     #[Column(type'datetime_immutable')]
  26.     private DateTimeImmutable $updatedAt;
  27.     #[ManyToOne(targetEntityFeature::class)]
  28.     #[JoinColumn(nullablefalseonDelete'CASCADE')]
  29.     #[Groups(['product'])]
  30.     private Feature $feature;
  31.     #[ManyToOne(targetEntityProduct::class, inversedBy'features')]
  32.     #[JoinColumn(nullabletrueonDelete'CASCADE')]
  33.     private ?Product $product null;
  34.     #[Column(type'text'nullabletrue)]
  35.     private ?string $value null;
  36.     #[Groups(['product'])]
  37.     private mixed $computedValue null;
  38.     public function __construct()
  39.     {
  40.         $this->updatedAt = new DateTimeImmutable();
  41.     }
  42.     public function getId(): ?int
  43.     {
  44.         return $this->id;
  45.     }
  46.     public function getFeature(): Feature
  47.     {
  48.         return $this->feature;
  49.     }
  50.     public function setFeature(Feature $feature): void
  51.     {
  52.         $this->feature $feature;
  53.     }
  54.     public function getProduct(): ?Product
  55.     {
  56.         return $this->product;
  57.     }
  58.     public function setProduct(?Product $product): void
  59.     {
  60.         $this->product $product;
  61.     }
  62.     public function getValue(): mixed
  63.     {
  64.         return $this->value;
  65.     }
  66.     public function setValue(mixed $value): void
  67.     {
  68.         $this->value $value;
  69.     }
  70.     public function getComputedValue(): mixed
  71.     {
  72.         return $this->computedValue;
  73.     }
  74.     public function setComputedValue(mixed $computedValue): void
  75.     {
  76.         $this->computedValue $computedValue;
  77.         $this->updatedAt = new DateTimeImmutable();
  78.     }
  79. }