vendor/nen/kennisbank-platform/src/Nen/Entity/Bolt/BoltFieldValue.php line 12

Open in your IDE?
  1. <?php
  2. namespace Nen\Bundle\KennisbankPlatformBundle\Entity\Bolt;
  3. use DateTime;
  4. use Doctrine\ORM\Mapping as ORM;
  5. /**
  6.  * @ORM\Table(name="bolt_field_value")
  7.  * @ORM\MappedSuperclass()
  8.  */
  9. class BoltFieldValue
  10. {
  11.     private array $fieldTypeMapping = [
  12.         'text' => 'text',
  13.         'integer' => 'integer',
  14.         'float' => 'float',
  15.         'geolocation' => 'text',
  16.         'imagelist' => 'text',
  17.         'image' => 'string',
  18.         'file' => 'string',
  19.         'filelist' => 'text',
  20.         'video' => 'string',
  21.         'html' => 'text',
  22.         'textarea' => 'text',
  23.         'markdown' => 'text',
  24.         'datetime' => 'datetime',
  25.         'date' => 'date',
  26.         'select' => 'jsonArray',
  27.         'templateselect' => 'jsonArray',
  28.         'checkbox' => 'boolean',
  29.         'number' => 'decimal',
  30.     ];
  31.     /**
  32.      * @ORM\Column(name="id", type="integer", nullable=false)
  33.      * @ORM\Id
  34.      * @ORM\GeneratedValue(strategy="IDENTITY")
  35.      */
  36.     private ?int $id null;
  37.     /**
  38.      * @ORM\Column(name="contenttype", type="string", length=64, nullable=false)
  39.      */
  40.     private string $contenttype;
  41.     /**
  42.      * @ORM\Column(name="content_id", type="integer", nullable=false)
  43.      */
  44.     private int $contentId;
  45.     /**
  46.      * @ORM\Column(name="name", type="string", length=64, nullable=false)
  47.      */
  48.     private string $name;
  49.     /**
  50.      * @ORM\Column(name="grouping", type="integer", nullable=false)
  51.      */
  52.     private int $grouping 0;
  53.     /**
  54.      * @ORM\Column(name="block", type="string", length=64, nullable=true)
  55.      */
  56.     private ?string $block null;
  57.     /**
  58.      * @ORM\Column(name="fieldname", type="string", length=255, nullable=false)
  59.      */
  60.     private string $fieldname;
  61.     /**
  62.      * @ORM\Column(name="fieldtype", type="string", length=255, nullable=false)
  63.      */
  64.     private string $fieldtype;
  65.     /**
  66.      * @ORM\Column(name="value_string", type="string", length=255, nullable=true)
  67.      */
  68.     private ?string $valueString null;
  69.     /**
  70.      * @ORM\Column(name="value_text", type="text", length=0, nullable=true)
  71.      */
  72.     private ?string $valueText null;
  73.     /**
  74.      * @ORM\Column(name="value_integer", type="integer", nullable=true)
  75.      */
  76.     private ?int $valueInteger null;
  77.     /**
  78.      * @ORM\Column(name="value_float", type="float", precision=10, scale=0, nullable=true)
  79.      */
  80.     private ?float $valueFloat null;
  81.     /**
  82.      * @ORM\Column(name="value_decimal", type="decimal", precision=18, scale=9, nullable=true)
  83.      */
  84.     private ?string $valueDecimal null;
  85.     /**
  86.      * @ORM\Column(name="value_date", type="date", nullable=true)
  87.      */
  88.     private ?DateTime $valueDate null;
  89.     /**
  90.      * @ORM\Column(name="value_datetime", type="datetime", nullable=true)
  91.      */
  92.     private ?DateTime $valueDatetime null;
  93.     /**
  94.      * @ORM\Column(name="value_json_array", type="json", nullable=false)
  95.      */
  96.     private array $valueJsonArray = [];
  97.     /**
  98.      * @ORM\Column(name="value_boolean", type="boolean", nullable=false)
  99.      */
  100.     private bool $valueBoolean false;
  101.     /**
  102.      * @return array|string[]
  103.      */
  104.     public function getFieldTypeMapping(): array
  105.     {
  106.         return $this->fieldTypeMapping;
  107.     }
  108.     /**
  109.      * @param array|string[] $fieldTypeMapping
  110.      */
  111.     public function setFieldTypeMapping(array $fieldTypeMapping): self
  112.     {
  113.         $this->fieldTypeMapping $fieldTypeMapping;
  114.         return $this;
  115.     }
  116.     public function getId(): ?int
  117.     {
  118.         return $this->id;
  119.     }
  120.     public function getContenttype(): string
  121.     {
  122.         return $this->contenttype;
  123.     }
  124.     public function setContenttype(string $contenttype): self
  125.     {
  126.         $this->contenttype $contenttype;
  127.         return $this;
  128.     }
  129.     public function getContentId(): int
  130.     {
  131.         return $this->contentId;
  132.     }
  133.     public function setContentId(int $contentId): self
  134.     {
  135.         $this->contentId $contentId;
  136.         return $this;
  137.     }
  138.     public function getName(): string
  139.     {
  140.         return $this->name;
  141.     }
  142.     public function setName(string $name): self
  143.     {
  144.         $this->name $name;
  145.         return $this;
  146.     }
  147.     public function getGrouping(): int
  148.     {
  149.         return $this->grouping;
  150.     }
  151.     public function setGrouping(int $grouping): self
  152.     {
  153.         $this->grouping $grouping;
  154.         return $this;
  155.     }
  156.     public function getBlock(): ?string
  157.     {
  158.         return $this->block;
  159.     }
  160.     public function setBlock(?string $block): self
  161.     {
  162.         $this->block $block;
  163.         return $this;
  164.     }
  165.     public function getFieldname(): string
  166.     {
  167.         return $this->fieldname;
  168.     }
  169.     public function setFieldname(string $fieldname): self
  170.     {
  171.         $this->fieldname $fieldname;
  172.         return $this;
  173.     }
  174.     public function getFieldtype(): string
  175.     {
  176.         return $this->fieldtype;
  177.     }
  178.     public function setFieldtype(string $fieldtype): self
  179.     {
  180.         $this->fieldtype $fieldtype;
  181.         return $this;
  182.     }
  183.     public function getValueString(): ?string
  184.     {
  185.         return $this->valueString;
  186.     }
  187.     public function setValueString(?string $valueString): self
  188.     {
  189.         $this->valueString $valueString;
  190.         return $this;
  191.     }
  192.     public function getValueText(): ?string
  193.     {
  194.         return $this->valueText;
  195.     }
  196.     public function setValueText(?string $valueText): self
  197.     {
  198.         $this->valueText $valueText;
  199.         return $this;
  200.     }
  201.     public function getValueInteger(): ?int
  202.     {
  203.         return $this->valueInteger;
  204.     }
  205.     public function setValueInteger(?int $valueInteger): self
  206.     {
  207.         $this->valueInteger $valueInteger;
  208.         return $this;
  209.     }
  210.     public function getValueFloat(): ?float
  211.     {
  212.         return $this->valueFloat;
  213.     }
  214.     public function setValueFloat(?float $valueFloat): self
  215.     {
  216.         $this->valueFloat $valueFloat;
  217.         return $this;
  218.     }
  219.     public function getValueDecimal(): ?string
  220.     {
  221.         return $this->valueDecimal;
  222.     }
  223.     public function setValueDecimal(?string $valueDecimal): self
  224.     {
  225.         $this->valueDecimal $valueDecimal;
  226.         return $this;
  227.     }
  228.     public function getValueDate(): ?DateTime
  229.     {
  230.         return $this->valueDate;
  231.     }
  232.     public function setValueDate(?DateTime $valueDate): self
  233.     {
  234.         $this->valueDate $valueDate;
  235.         return $this;
  236.     }
  237.     public function getValueDatetime(): ?DateTime
  238.     {
  239.         return $this->valueDatetime;
  240.     }
  241.     public function setValueDatetime(?DateTime $valueDatetime): self
  242.     {
  243.         $this->valueDatetime $valueDatetime;
  244.         return $this;
  245.     }
  246.     public function getValueJsonArray(): array
  247.     {
  248.         return $this->valueJsonArray;
  249.     }
  250.     public function setValueJsonArray(array $valueJsonArray): self
  251.     {
  252.         $this->valueJsonArray $valueJsonArray;
  253.         return $this;
  254.     }
  255.     public function getValueBoolean(): bool
  256.     {
  257.         return $this->valueBoolean;
  258.     }
  259.     public function setValueBoolean(bool $valueBoolean): self
  260.     {
  261.         $this->valueBoolean $valueBoolean;
  262.         return $this;
  263.     }
  264.     /**
  265.      * @return mixed
  266.      */
  267.     public function getValue()
  268.     {
  269.         if (!isset($this->fieldTypeMapping[$this->fieldtype])) {
  270.             return null;
  271.         }
  272.         $field $this->fieldTypeMapping[$this->fieldtype];
  273.         $method 'getValue'.ucfirst($field);
  274.         if (!method_exists($this$method)) {
  275.             return null;
  276.         }
  277.         return $this->$method();
  278.     }
  279. }