<?php
namespace Nen\Bundle\KennisbankPlatformBundle\Entity\Bolt;
use DateTime;
use Doctrine\ORM\Mapping as ORM;
/**
* @ORM\Table(name="bolt_field_value")
* @ORM\MappedSuperclass()
*/
class BoltFieldValue
{
private array $fieldTypeMapping = [
'text' => 'text',
'integer' => 'integer',
'float' => 'float',
'geolocation' => 'text',
'imagelist' => 'text',
'image' => 'string',
'file' => 'string',
'filelist' => 'text',
'video' => 'string',
'html' => 'text',
'textarea' => 'text',
'markdown' => 'text',
'datetime' => 'datetime',
'date' => 'date',
'select' => 'jsonArray',
'templateselect' => 'jsonArray',
'checkbox' => 'boolean',
'number' => 'decimal',
];
/**
* @ORM\Column(name="id", type="integer", nullable=false)
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private ?int $id = null;
/**
* @ORM\Column(name="contenttype", type="string", length=64, nullable=false)
*/
private string $contenttype;
/**
* @ORM\Column(name="content_id", type="integer", nullable=false)
*/
private int $contentId;
/**
* @ORM\Column(name="name", type="string", length=64, nullable=false)
*/
private string $name;
/**
* @ORM\Column(name="grouping", type="integer", nullable=false)
*/
private int $grouping = 0;
/**
* @ORM\Column(name="block", type="string", length=64, nullable=true)
*/
private ?string $block = null;
/**
* @ORM\Column(name="fieldname", type="string", length=255, nullable=false)
*/
private string $fieldname;
/**
* @ORM\Column(name="fieldtype", type="string", length=255, nullable=false)
*/
private string $fieldtype;
/**
* @ORM\Column(name="value_string", type="string", length=255, nullable=true)
*/
private ?string $valueString = null;
/**
* @ORM\Column(name="value_text", type="text", length=0, nullable=true)
*/
private ?string $valueText = null;
/**
* @ORM\Column(name="value_integer", type="integer", nullable=true)
*/
private ?int $valueInteger = null;
/**
* @ORM\Column(name="value_float", type="float", precision=10, scale=0, nullable=true)
*/
private ?float $valueFloat = null;
/**
* @ORM\Column(name="value_decimal", type="decimal", precision=18, scale=9, nullable=true)
*/
private ?string $valueDecimal = null;
/**
* @ORM\Column(name="value_date", type="date", nullable=true)
*/
private ?DateTime $valueDate = null;
/**
* @ORM\Column(name="value_datetime", type="datetime", nullable=true)
*/
private ?DateTime $valueDatetime = null;
/**
* @ORM\Column(name="value_json_array", type="json", nullable=false)
*/
private array $valueJsonArray = [];
/**
* @ORM\Column(name="value_boolean", type="boolean", nullable=false)
*/
private bool $valueBoolean = false;
/**
* @return array|string[]
*/
public function getFieldTypeMapping(): array
{
return $this->fieldTypeMapping;
}
/**
* @param array|string[] $fieldTypeMapping
*/
public function setFieldTypeMapping(array $fieldTypeMapping): self
{
$this->fieldTypeMapping = $fieldTypeMapping;
return $this;
}
public function getId(): ?int
{
return $this->id;
}
public function getContenttype(): string
{
return $this->contenttype;
}
public function setContenttype(string $contenttype): self
{
$this->contenttype = $contenttype;
return $this;
}
public function getContentId(): int
{
return $this->contentId;
}
public function setContentId(int $contentId): self
{
$this->contentId = $contentId;
return $this;
}
public function getName(): string
{
return $this->name;
}
public function setName(string $name): self
{
$this->name = $name;
return $this;
}
public function getGrouping(): int
{
return $this->grouping;
}
public function setGrouping(int $grouping): self
{
$this->grouping = $grouping;
return $this;
}
public function getBlock(): ?string
{
return $this->block;
}
public function setBlock(?string $block): self
{
$this->block = $block;
return $this;
}
public function getFieldname(): string
{
return $this->fieldname;
}
public function setFieldname(string $fieldname): self
{
$this->fieldname = $fieldname;
return $this;
}
public function getFieldtype(): string
{
return $this->fieldtype;
}
public function setFieldtype(string $fieldtype): self
{
$this->fieldtype = $fieldtype;
return $this;
}
public function getValueString(): ?string
{
return $this->valueString;
}
public function setValueString(?string $valueString): self
{
$this->valueString = $valueString;
return $this;
}
public function getValueText(): ?string
{
return $this->valueText;
}
public function setValueText(?string $valueText): self
{
$this->valueText = $valueText;
return $this;
}
public function getValueInteger(): ?int
{
return $this->valueInteger;
}
public function setValueInteger(?int $valueInteger): self
{
$this->valueInteger = $valueInteger;
return $this;
}
public function getValueFloat(): ?float
{
return $this->valueFloat;
}
public function setValueFloat(?float $valueFloat): self
{
$this->valueFloat = $valueFloat;
return $this;
}
public function getValueDecimal(): ?string
{
return $this->valueDecimal;
}
public function setValueDecimal(?string $valueDecimal): self
{
$this->valueDecimal = $valueDecimal;
return $this;
}
public function getValueDate(): ?DateTime
{
return $this->valueDate;
}
public function setValueDate(?DateTime $valueDate): self
{
$this->valueDate = $valueDate;
return $this;
}
public function getValueDatetime(): ?DateTime
{
return $this->valueDatetime;
}
public function setValueDatetime(?DateTime $valueDatetime): self
{
$this->valueDatetime = $valueDatetime;
return $this;
}
public function getValueJsonArray(): array
{
return $this->valueJsonArray;
}
public function setValueJsonArray(array $valueJsonArray): self
{
$this->valueJsonArray = $valueJsonArray;
return $this;
}
public function getValueBoolean(): bool
{
return $this->valueBoolean;
}
public function setValueBoolean(bool $valueBoolean): self
{
$this->valueBoolean = $valueBoolean;
return $this;
}
/**
* @return mixed
*/
public function getValue()
{
if (!isset($this->fieldTypeMapping[$this->fieldtype])) {
return null;
}
$field = $this->fieldTypeMapping[$this->fieldtype];
$method = 'getValue'.ucfirst($field);
if (!method_exists($this, $method)) {
return null;
}
return $this->$method();
}
}