71 lines
1.3 KiB
PHP
71 lines
1.3 KiB
PHP
<?php
|
|
|
|
namespace Ardent\ParameterBundle\Entity;
|
|
|
|
use Doctrine\DBAL\Types\TextType;
|
|
use Doctrine\ORM\Mapping as ORM;
|
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
|
use Symfony\Component\Form\Extension\Core\Type\NumberType;
|
|
|
|
/**
|
|
* @ORM\Entity
|
|
* @ORM\Table(name="parameter_bundle_parameters")
|
|
*/
|
|
class Parameter
|
|
{
|
|
/**
|
|
* @ORM\Id
|
|
* @ORM\GeneratedValue(strategy="AUTO")
|
|
* @ORM\Column(type="integer")
|
|
*/
|
|
private ?int $id;
|
|
|
|
/**
|
|
* @ORM\Column(type="string")
|
|
*/
|
|
private ?string $name;
|
|
|
|
/**
|
|
* @ORM\Column(type="string")
|
|
*/
|
|
private mixed $value;
|
|
|
|
public function getId(): int
|
|
{
|
|
return $this->id;
|
|
}
|
|
|
|
public function getName(): string
|
|
{
|
|
return $this->name;
|
|
}
|
|
|
|
public function setName(string $name): self
|
|
{
|
|
$this->name = $name;
|
|
return $this;
|
|
}
|
|
|
|
public function getValue(): mixed
|
|
{
|
|
return $this->value;
|
|
}
|
|
|
|
static function parseValue(mixed $value, string $type): mixed
|
|
{
|
|
return match ($type) {
|
|
NumberType::class => intval($value),
|
|
CheckboxType::class => boolval($value),
|
|
default => $value,
|
|
};
|
|
}
|
|
|
|
public function setValue(mixed $value): self
|
|
{
|
|
$this->value = $value;
|
|
return $this;
|
|
}
|
|
|
|
|
|
}
|