ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
class.ilDclFieldProperty.php
Go to the documentation of this file.
1<?php
2
19declare(strict_types=1);
20
22{
33 protected ?int $id;
41 protected int $field_id = 0;
49 protected string $name = "";
56 protected $value;
57
61 public function __construct(?int $primary_key = 0)
62 {
63 parent::__construct($primary_key);
64 }
65
69 public static function returnDbTableName(): string
70 {
71 return "il_dcl_field_prop";
72 }
73
74 public function getId(): int
75 {
76 return $this->id;
77 }
78
79 public function setId(int $id): void
80 {
81 $this->id = $id;
82 }
83
84 public function getFieldId(): int
85 {
86 return $this->field_id;
87 }
88
89 public function setFieldId(int $field_id): void
90 {
91 $this->field_id = $field_id;
92 }
93
94 public function getName(): string
95 {
96 return $this->name;
97 }
98
99 public function setName(string $name): void
100 {
101 $this->name = $name;
102 }
103
104 public function getValue(): string
105 {
106 return $this->value;
107 }
108
112 public function setValue($value): void
113 {
114 $this->value = $value;
115 }
116
117 public function create(): void
118 {
119 $this->value = $this->serializeData($this->value);
120 parent::create();
121 }
122
123 public function update(): void
124 {
125 $this->value = $this->serializeData($this->value);
126 parent::update();
127 }
128
129 public function afterObjectLoad(): void
130 {
131 $this->value = $this->deserializeData($this->value);
132 }
133
138 public function serializeData($value): string
139 {
140 if (is_array($value)) {
141 $value = json_encode($value);
142 }
143
144 return (string) $value;
145 }
146
151 public function deserializeData(string $value)
152 {
153 $deserialize = json_decode($value, true);
154 if (is_array($deserialize)) {
155 return $deserialize;
156 }
157
158 return $value;
159 }
160}
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
serializeData($value)
Serialize data before storing to db.
static returnDbTableName()
@description Return the Name of your Database Table
deserializeData(string $value)
Deserialize data before applying to field.
__construct(?int $primary_key=0)
ilDclFieldProperty constructor.
__construct(Container $dic, ilPlugin $plugin)
@inheritDoc