ILIAS  release_8 Revision v8.24
class.ilDclFieldProperty.php
Go to the documentation of this file.
1<?php
2
20{
31 protected ?int $id;
39 protected int $field_id = 0;
47 protected string $name = "";
54 protected $value;
55
59 public function __construct(?int $primary_key = 0)
60 {
61 parent::__construct($primary_key);
62 }
63
67 public static function returnDbTableName(): string
68 {
69 return "il_dcl_field_prop";
70 }
71
72 public function getId(): int
73 {
74 return $this->id;
75 }
76
77 public function setId(int $id): void
78 {
79 $this->id = $id;
80 }
81
82 public function getFieldId(): int
83 {
84 return $this->field_id;
85 }
86
87 public function setFieldId(int $field_id): void
88 {
89 $this->field_id = $field_id;
90 }
91
92 public function getName(): string
93 {
94 return $this->name;
95 }
96
97 public function setName(string $name): void
98 {
99 $this->name = $name;
100 }
101
105 public function getValue()
106 {
107 return $this->value;
108 }
109
113 public function setValue($value): void
114 {
115 $this->value = $value;
116 }
117
118 public function create(): void
119 {
120 $this->value = $this->serializeData($this->value);
121 parent::create();
122 }
123
124 public function update(): void
125 {
126 $this->value = $this->serializeData($this->value);
127 parent::update();
128 }
129
130 public function afterObjectLoad(): void
131 {
132 $this->value = $this->deserializeData($this->value);
133 }
134
139 public function serializeData($value): string
140 {
141 if (is_array($value)) {
142 $value = json_encode($value);
143 }
144
145 return (string) $value;
146 }
147
152 public function deserializeData(string $value)
153 {
154 $deserialize = json_decode($value, true);
155 if (is_array($deserialize)) {
156 return $deserialize;
157 }
158
159 return $value;
160 }
161}
Class ActiveRecord.
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