58 if (!empty(self::$record_field_cache[$field->
getId()][$record->
getId()])) {
59 return self::$record_field_cache[$field->
getId()][$record->
getId()];
62 $path = self::getClassPathByInstance($field, self::$record_field_class_patter);
63 if (file_exists($path)) {
64 $class = self::getClassByInstance($field, self::$record_field_class_patter);
65 $instance =
new $class($record, $field);
67 if (!$instance->getFieldRepresentation()) {
68 $instance->setFieldRepresentation(self::getFieldRepresentationInstance($field));
71 if (!$instance->getRecordRepresentation()) {
72 $instance->setRecordRepresentation(self::getRecordRepresentationInstance($instance));
74 self::$record_field_cache[$field->
getId()][$record->
getId()] = $instance;
98 if (!empty(self::$field_class_cache[$datatype . $class_pattern])) {
99 return self::$field_class_cache[$datatype . $class_pattern];
102 $fieldtype = $datatype;
104 $class = sprintf($class_pattern, $fieldtype);
105 self::$field_class_cache[$datatype . $class_pattern] = $class;
121 return "class." . self::getFieldClass($datatype, $class_pattern) .
".php";
142 if ($field->
getId() != null && !empty(self::$field_representation_cache[$field->
getId()])) {
143 return self::$field_representation_cache[$field->
getId()];
146 $class_path = self::getClassPathByInstance($field, self::$field_representation_class_pattern);
149 if (file_exists($class_path)) {
150 $class = self::getClassByInstance($field, self::$field_representation_class_pattern);
151 $instance =
new $class($field);
153 throw new ilDclException(
"Path for FieldRepresentation with file " . $class_path .
" does not exists!");
156 if ($instance == null) {
157 throw new ilDclException(
"Could not create FieldRepresentation of " . $class .
" with file " . $class_path);
160 if ($field->
getId() != null) {
161 self::$field_representation_cache[$field->
getId()] = $instance;
185 if ($record_field->
getId() != null && !empty(self::$record_representation_cache[$record_field->
getId()])) {
186 return self::$record_representation_cache[$record_field->
getId()];
189 $class_path = self::getClassPathByInstance($record_field->
getField(), self::$record_representation_class_pattern);
192 if (file_exists($class_path)) {
193 $class = self::getClassByInstance($record_field->
getField(), self::$record_representation_class_pattern);
195 $class = self::getFieldClass(self::$default_prefix .
"Base", self::$record_representation_class_pattern);
198 $instance =
new $class($record_field);
200 if ($instance == null) {
201 throw new ilDclException(
"Could not create RecordRepresentation of " . $class_path .
" " . $record_field->
getField()->getDatatype()->getTitle());
204 if ($record_field->
getId() != null) {
205 self::$record_representation_cache[$record_field->
getId()] = $instance;
224 if ($datatype != null) {
225 $base->setDatatypeId($datatype);
228 $ilDclBaseFieldModel = self::getFieldModelInstanceByClass(
$base, $field_id);
230 return $ilDclBaseFieldModel;
252 if ($field->
getId() != null && !empty(self::$field_model_cache[$field->
getId()])) {
253 return self::$field_model_cache[$field->
getId()];
256 $path_type = self::getClassPathByInstance($field, self::$field_class_patter);
258 if (file_exists($path_type)) {
259 $class = self::getClassByInstance($field, self::$field_class_patter);
261 $class = self::getFieldClass(self::$default_prefix .
"Base", self::$field_class_patter);
265 $instance =
new $class($field_id);
267 $instance =
new $class();
270 if ($instance == null) {
271 throw new ilDclException(
"Could not create FieldModel of " . $class);
274 if ($field->
getId() != null) {
275 self::$field_model_cache[$field->
getId()] = $instance;
298 if (!empty(self::$field_type_cache[$datatype->getId()])) {
300 if (!empty(self::$field_type_cache[$datatype->getId()][$field->
getId()])) {
301 return self::$field_type_cache[$datatype->getId()][$field->
getId()];
304 return self::$field_type_cache[$datatype->getId()];
312 $fieldtype = $plugin_data->getPluginClassPrefix() . ucfirst($plugin_data->getPluginName());
314 $fieldtype = self::$default_prefix . ucfirst(self::parseDatatypeTitle($datatype->getTitle()));
316 self::$field_type_cache[$datatype->getId()][$field->
getId()] = $fieldtype;
318 $fieldtype = self::$default_prefix . ucfirst(self::parseDatatypeTitle($datatype->getTitle()));
319 self::$field_type_cache[$datatype->getId()] = $fieldtype;
334 $fieldtype = self::getFieldTypeByInstance($field);
336 return self::getFieldClass($fieldtype, $class_pattern);
357 if ($field->
getId() != null && !empty(self::$class_path_cache[$field->
getId()][$class_pattern])) {
358 return self::$class_path_cache[$field->
getId()][$class_pattern];
365 if ($plugin_data == null) {
367 "Something went wrong by initializing the FieldHook-Plugin '" 374 $class_path = $plugin_data->getDirectory() .
"/classes/";
376 $class_path = sprintf(self::$field_base_path_patter, ucfirst(self::parseDatatypeTitle($datatype->getTitle())));
379 $class_path = sprintf(self::$field_base_path_patter, ucfirst(self::parseDatatypeTitle($datatype->getTitle())));
382 $return = $class_path . self::getFieldClassFile(self::getFieldTypeByInstance($field), $class_pattern);
384 if ($field->
getId() != null) {
385 self::$class_path_cache[$field->
getId()][$class_pattern] = $return;
402 $parts = explode(
"_", $title);
403 $func =
function ($value) {
404 return ucfirst($value);
407 $parts = array_map($func, $parts);
408 $title = implode(
"", $parts);
436 $class_name = get_class($object);
437 $class_name = substr($class_name, 2, -(strlen(self::$field_class_patter) - 2));
Class ilDclBaseFieldModel.
static getPluginObject(string $a_ctype, string $a_cname, string $a_slot_id, string $a_pname)
static $field_representation_cache
static $field_class_patter
Class ilDclBaseFieldModel.
static $record_field_class_patter
static getFieldTypeByInstance(ilDclBaseFieldModel $field)
static $field_class_cache
static $field_model_cache
static getFieldRepresentationInstance(ilDclBaseFieldModel $field)
Returns FieldRepresentation from BaseFieldModel.
static $record_class_patter
static $record_representation_cache
static $record_representation_class_pattern
static parseDatatypeTitle($title)
Parse string to FieldClass format Replaces _ with camelcase-notation.
const PROP_PLUGIN_HOOK_NAME
static $field_representation_class_pattern
static getRecordFieldInstance(ilDclBaseFieldModel $field, ilDclBaseRecordModel $record)
Creates a RecordField instance and loads the field and record representation.
static getFieldClass($datatype, $class_pattern)
Concatenates Classname from datatype and pattern.
static getClassByInstance(ilDclBaseFieldModel $field, $class_pattern)
static getFieldModelInstance($field_id, $datatype=null)
Get FieldModel from field-id and datatype.
hasProperty($key)
Checks if a certain property for a field is set.
static $record_field_cache
static getFieldClassFile($datatype, $class_pattern)
Get Filename from datatype and pattern.
Class ilDclFieldFactory This Class handles the creation of all field-classes.
static getRecordRepresentationInstance(ilDclBaseRecordFieldModel $record_field)
Get RecordRepresentation from RecordFieldModel.
static $field_base_path_patter
static getFieldModelInstanceByClass(ilDclBaseFieldModel $field, $field_id=null)
Gets the correct instance of a fieldModel class Checks if a field is a plugin a replaces the fieldMod...
Class ilDclBaseRecordModel.
getProperty($key)
Returns a certain property of a field.
static getClassPathByInstance(ilDclBaseFieldModel $field, $class_pattern)
static getPluginNameFromFieldModel(ilDclBaseFieldModel $object)
Get plugin-name from FieldModel.
static getRecordModelInstance($record_id)
Creates a RecordModel instance.