<?php
declare(strict_types=1);
namespace App\Shop\Doctrine\Entity;
use App\Shop\Doctrine\EntityListener\FeatureValueListener;
use DateTimeImmutable;
use Doctrine\ORM\Mapping\Column;
use Doctrine\ORM\Mapping\Entity;
use Doctrine\ORM\Mapping\EntityListeners;
use Doctrine\ORM\Mapping\GeneratedValue;
use Doctrine\ORM\Mapping\Id;
use Doctrine\ORM\Mapping\JoinColumn;
use Doctrine\ORM\Mapping\ManyToOne;
use Doctrine\ORM\Mapping\Table;
use Symfony\Component\Serializer\Annotation\Groups;
#[Entity]
#[EntityListeners([FeatureValueListener::class])]
#[Table(name: '`shop_feature_value`')]
class FeatureValue
{
#[Id]
#[Column(type: 'integer')]
#[GeneratedValue]
#[Groups(['product'])]
private ?int $id = null;
#[Column(type: 'datetime_immutable')]
private DateTimeImmutable $updatedAt;
#[ManyToOne(targetEntity: Feature::class)]
#[JoinColumn(nullable: false, onDelete: 'CASCADE')]
#[Groups(['product'])]
private Feature $feature;
#[ManyToOne(targetEntity: Product::class, inversedBy: 'features')]
#[JoinColumn(nullable: true, onDelete: 'CASCADE')]
private ?Product $product = null;
#[Column(type: 'text', nullable: true)]
private ?string $value = null;
#[Groups(['product'])]
private mixed $computedValue = null;
public function __construct()
{
$this->updatedAt = new DateTimeImmutable();
}
public function getId(): ?int
{
return $this->id;
}
public function getFeature(): Feature
{
return $this->feature;
}
public function setFeature(Feature $feature): void
{
$this->feature = $feature;
}
public function getProduct(): ?Product
{
return $this->product;
}
public function setProduct(?Product $product): void
{
$this->product = $product;
}
public function getValue(): mixed
{
return $this->value;
}
public function setValue(mixed $value): void
{
$this->value = $value;
}
public function getComputedValue(): mixed
{
return $this->computedValue;
}
public function setComputedValue(mixed $computedValue): void
{
$this->computedValue = $computedValue;
$this->updatedAt = new DateTimeImmutable();
}
}