38 if (!empty(self::$record_field_cache[$field->getId()][$record->getId()])) {
39 return self::$record_field_cache[$field->getId()][$record->getId()];
42 $path = self::getClassPathByInstance($field, self::$record_field_class_patter);
43 if (file_exists(
$path)) {
44 $class = self::getClassByInstance($field, self::$record_field_class_patter);
45 $instance =
new $class($record, $field);
47 if (!$instance->getFieldRepresentation()) {
48 $instance->setFieldRepresentation(self::getFieldRepresentationInstance($field));
51 if (!$instance->getRecordRepresentation()) {
52 $instance->setRecordRepresentation(self::getRecordRepresentationInstance($instance));
54 self::$record_field_cache[$field->getId()][$record->getId()] = $instance;
68 public static function getFieldClass(
string $datatype,
string $class_pattern): string
70 if (!empty(self::$field_class_cache[$datatype . $class_pattern])) {
71 return self::$field_class_cache[$datatype . $class_pattern];
74 $fieldtype = $datatype;
76 $class = sprintf($class_pattern, $fieldtype);
77 self::$field_class_cache[$datatype . $class_pattern] = $class;
84 return "class." . self::getFieldClass($datatype, $class_pattern) .
".php";
92 if ($field->
getId() != null && !empty(self::$field_representation_cache[$field->
getId()])) {
93 return self::$field_representation_cache[$field->
getId()];
96 $class_path = self::getClassPathByInstance($field, self::$field_representation_class_pattern);
99 if (file_exists($class_path)) {
100 $class = self::getClassByInstance($field, self::$field_representation_class_pattern);
101 $instance =
new $class($field);
103 throw new ilDclException(
"Path for FieldRepresentation with file " . $class_path .
" does not exists!");
106 if ($instance == null) {
107 throw new ilDclException(
"Could not create FieldRepresentation of " . $class .
" with file " . $class_path);
110 if ($field->
getId() != null) {
111 self::$field_representation_cache[$field->
getId()] = $instance;
127 if ($record_field->
getId() != null && !empty(self::$record_representation_cache[$record_field->
getId()])) {
128 return self::$record_representation_cache[$record_field->
getId()];
131 $class_path = self::getClassPathByInstance(
133 self::$record_representation_class_pattern
137 if (file_exists($class_path)) {
138 $class = self::getClassByInstance($record_field->
getField(), self::$record_representation_class_pattern);
140 $class = self::getFieldClass(self::$default_prefix .
"Base", self::$record_representation_class_pattern);
143 $instance =
new $class($record_field);
145 if ($instance == null) {
146 throw new ilDclException(
"Could not create RecordRepresentation of " . $class_path .
" " . $record_field->
getField()->getDatatype()->getTitle());
149 if ($record_field->
getId() != null) {
150 self::$record_representation_cache[$record_field->
getId()] = $instance;
163 if ($datatype != null) {
164 $base->setDatatypeId($datatype);
167 $ilDclBaseFieldModel = self::getFieldModelInstanceByClass(
$base, $field_id);
169 return $ilDclBaseFieldModel;
181 ?
int $field_id = null
183 if ($field->
getId() != null && !empty(self::$field_model_cache[$field->
getId()])) {
184 return self::$field_model_cache[$field->
getId()];
187 $path_type = self::getClassPathByInstance($field, self::$field_class_patter);
189 if (file_exists($path_type)) {
190 $class = self::getClassByInstance($field, self::$field_class_patter);
192 $class = self::getFieldClass(self::$default_prefix .
"Base", self::$field_class_patter);
196 $instance =
new $class($field_id);
198 $instance =
new $class();
201 if ($instance == null) {
202 throw new ilDclException(
"Could not create FieldModel of " . $class);
206 if ($field->
getId() != null) {
207 self::$field_model_cache[$field->
getId()] = $instance;
220 if (!empty(self::$field_type_cache[$datatype->getId()])) {
221 return self::$field_type_cache[$datatype->getId()];
226 if ($DIC[
"component.repository"]->hasActivatedPlugin($plugin_id)) {
227 $fieldtype =
'il' . $DIC[
"component.repository"]->getPluginById($plugin_id)->getName();
232 $fieldtype = self::$default_prefix . ucfirst(self::parseDatatypeTitle($datatype->getTitle()));
234 self::$field_type_cache[$datatype->getId()] = $fieldtype;
240 $fieldtype = self::getFieldTypeByInstance($field);
242 return self::getFieldClass($fieldtype, $class_pattern);
255 if ($field->
getId() != null && !empty(self::$class_path_cache[$field->
getId()][$class_pattern])) {
256 return self::$class_path_cache[$field->
getId()][$class_pattern];
261 if ($DIC[
"component.repository"]->hasActivatedPlugin($plugin_id)) {
262 $class_path = $DIC[
"component.repository"]->getPluginById($plugin_id)->getPath() .
'/classes/';
267 $class_path = sprintf(
268 self::$field_base_path_patter,
269 ucfirst(self::parseDatatypeTitle($datatype->getTitle()))
273 $return = $class_path . self::getFieldClassFile(self::getFieldTypeByInstance($field), $class_pattern);
275 if ($field->
getId() != null) {
276 self::$class_path_cache[$field->
getId()][$class_pattern] = $return;
288 $parts = explode(
"_", $title);
289 $func =
function ($value) {
290 return ucfirst($value);
294 $title = implode(
"",
$parts);
306 $class_name = get_class($object);
307 $class_name = substr($class_name, 2, -(strlen(self::$field_class_patter) - 2));
static array $record_representation_cache
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getFieldClass(string $datatype, string $class_pattern)
Concatenates Classname from datatype and pattern.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static array $class_path_cache
if($clientAssertionType !='urn:ietf:params:oauth:client-assertion-type:jwt-bearer'|| $grantType !='client_credentials') $parts
static getClassPathByInstance(ilDclBaseFieldModel $field, string $class_pattern)
static getFieldTypeByInstance(ilDclBaseFieldModel $field)
static getFieldRepresentationInstance(ilDclBaseFieldModel $field)
static getRecordModelInstance(?int $record_id)
static isPluginDatatype(string $datatype)
static array $field_type_cache
static array $field_class_cache
static getClassByInstance(ilDclBaseFieldModel $field, string $class_pattern)
static getPluginId(string $datatype)
static string $field_class_patter
static string $default_prefix
static string $field_base_path_patter
static string $record_representation_class_pattern
static array $record_field_cache
static parseDatatypeTitle(string $title)
Parse string to FieldClass format Replaces _ with camelcase-notation.
static getFieldModelInstanceByClass(ilDclBaseFieldModel $field, ?int $field_id=null)
Gets the correct instance of a fieldModel class Checks if a field is a plugin a replaces the fieldMod...
static getFieldModelInstance(int $field_id, ?int $datatype=null)
Get FieldModel from field-id and datatype.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getRecordFieldInstance(object $field, object $record)
Creates a RecordField instance and loads the field and record representation.
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getRecordRepresentationInstance(ilDclBaseRecordFieldModel $record_field)
Get RecordRepresentation from RecordFieldModel.
static array $field_representation_cache
static string $record_field_class_patter
static getFieldClassFile(string $datatype, string $class_pattern)
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static array $field_model_cache
This file is part of ILIAS, a powerful learning management system published by ILIAS open source e-Le...
static getPluginNameFromFieldModel(ilDclBaseFieldModel $object)
getDatatypeId()
Get datatype_id.
static string $field_representation_class_pattern