Class ilDclFieldFactory This Class handles the creation of all field-classes.
More...
Class ilDclFieldFactory This Class handles the creation of all field-classes.
- Author
- Michael Herren mh@st.nosp@m.uder.nosp@m.-raim.nosp@m.ann..nosp@m.ch
- Version
- 1.0.0
Definition at line 10 of file class.ilDclFieldFactory.php.
◆ getClassByInstance()
- Parameters
-
- Returns
- string
Definition at line 335 of file class.ilDclFieldFactory.php.
337 $fieldtype = self::getFieldTypeByInstance($field);
339 return self::getFieldClass($fieldtype, $class_pattern);
◆ getClassPathByInstance()
static ilDclFieldFactory::getClassPathByInstance |
( |
ilDclBaseFieldModel |
$field, |
|
|
|
$class_pattern |
|
) |
| |
|
static |
- Parameters
-
- Returns
- string
- Exceptions
-
Definition at line 356 of file class.ilDclFieldFactory.php.
References ilDclFieldTypePlugin\COMPONENT_NAME, ilDclBaseFieldModel\getDatatype(), ilDclBaseFieldModel\getId(), ilPlugin\getPluginObject(), ilDclBaseFieldModel\getProperty(), ilDclBaseFieldModel\getTitle(), ilDclBaseFieldModel\hasProperty(), IL_COMP_MODULE, ilDclDatatype\INPUTFORMAT_PLUGIN, ilDclBaseFieldModel\PROP_PLUGIN_HOOK_NAME, and ilDclFieldTypePlugin\SLOT_ID.
360 if ($field->
getId() != null && !empty(self::$class_path_cache[$field->
getId()][$class_pattern])) {
361 return self::$class_path_cache[$field->
getId()][$class_pattern];
367 if ($plugin_data == null) {
368 throw new ilDclException(
"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;
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get plugin object.
const PROP_PLUGIN_HOOK_NAME
hasProperty($key)
Checks if a certain property for a field is set.
getProperty($key)
Returns a certain property of a field.
◆ getFieldClass()
static ilDclFieldFactory::getFieldClass |
( |
|
$datatype, |
|
|
|
$class_pattern |
|
) |
| |
|
static |
Concatenates Classname from datatype and pattern.
- Parameters
-
- Returns
- string
Definition at line 97 of file class.ilDclFieldFactory.php.
99 if (!empty(self::$field_class_cache[$datatype . $class_pattern])) {
100 return self::$field_class_cache[$datatype . $class_pattern];
103 $fieldtype = $datatype;
105 $class = sprintf($class_pattern, $fieldtype);
106 self::$field_class_cache[$datatype . $class_pattern] = $class;
◆ getFieldClassFile()
static ilDclFieldFactory::getFieldClassFile |
( |
|
$datatype, |
|
|
|
$class_pattern |
|
) |
| |
|
static |
Get Filename from datatype and pattern.
- Parameters
-
- Returns
- string
Definition at line 120 of file class.ilDclFieldFactory.php.
122 return "class." . self::getFieldClass($datatype, $class_pattern) .
".php";
◆ getFieldModelInstance()
static ilDclFieldFactory::getFieldModelInstance |
( |
|
$field_id, |
|
|
|
$datatype = null |
|
) |
| |
|
static |
◆ getFieldModelInstanceByClass()
static ilDclFieldFactory::getFieldModelInstanceByClass |
( |
ilDclBaseFieldModel |
$field, |
|
|
|
$field_id = null |
|
) |
| |
|
static |
Gets the correct instance of a fieldModel class Checks if a field is a plugin a replaces the fieldModel with the necessary class.
- Parameters
-
- Returns
- ilDclBaseFieldModel
- Exceptions
-
Definition at line 253 of file class.ilDclFieldFactory.php.
References ilDclBaseFieldModel\getId().
Referenced by ilDclCache\buildFieldFromRecord(), and ilDclFieldEditGUI\checkInput().
255 if ($field->
getId() != null && !empty(self::$field_model_cache[$field->
getId()])) {
256 return self::$field_model_cache[$field->
getId()];
259 $path_type = self::getClassPathByInstance($field, self::$field_class_patter);
261 if (file_exists($path_type)) {
262 require_once($path_type);
263 $class = self::getClassByInstance($field, self::$field_class_patter);
265 $class = self::getFieldClass(self::$default_prefix .
"Base", self::$field_class_patter);
269 $instance =
new $class($field_id);
271 $instance =
new $class();
274 if ($instance == null) {
275 throw new ilDclException(
"Could not create FieldModel of " . $class);
278 if ($field->
getId() != null) {
279 self::$field_model_cache[$field->
getId()] = $instance;
◆ getFieldRepresentationInstance()
◆ getFieldTypeByInstance()
- Parameters
-
- Returns
- string
Definition at line 298 of file class.ilDclFieldFactory.php.
References ilDclFieldTypePlugin\COMPONENT_NAME, ilDclBaseFieldModel\getDatatype(), ilDclBaseFieldModel\getId(), ilPlugin\getPluginObject(), ilDclBaseFieldModel\getProperty(), ilDclBaseFieldModel\hasProperty(), IL_COMP_MODULE, ilDclDatatype\INPUTFORMAT_PLUGIN, ilDclBaseFieldModel\PROP_PLUGIN_HOOK_NAME, and ilDclFieldTypePlugin\SLOT_ID.
302 if (!empty(self::$field_type_cache[$datatype->getId()])) {
304 if (!empty(self::$field_type_cache[$datatype->getId()][$field->
getId()])) {
305 return self::$field_type_cache[$datatype->getId()][$field->
getId()];
308 return self::$field_type_cache[$datatype->getId()];
315 $fieldtype = $plugin_data->getPluginClassPrefix() . ucfirst($plugin_data->getPluginName());
317 $fieldtype = self::$default_prefix . ucfirst(self::parseDatatypeTitle($datatype->getTitle()));
319 self::$field_type_cache[$datatype->getId()][$field->
getId()] = $fieldtype;
321 $fieldtype = self::$default_prefix . ucfirst(self::parseDatatypeTitle($datatype->getTitle()));
322 self::$field_type_cache[$datatype->getId()] = $fieldtype;
static getPluginObject($a_ctype, $a_cname, $a_slot_id, $a_pname)
Get plugin object.
const PROP_PLUGIN_HOOK_NAME
hasProperty($key)
Checks if a certain property for a field is set.
getProperty($key)
Returns a certain property of a field.
◆ getPluginNameFromFieldModel()
◆ getRecordFieldInstance()
Creates a RecordField instance and loads the field and record representation.
- Parameters
-
- Returns
- mixed
- Exceptions
-
Definition at line 56 of file class.ilDclFieldFactory.php.
References $path, ilDclBaseFieldModel\getId(), and ilDclBaseRecordModel\getId().
Referenced by ilDclCache\getRecordFieldCache().
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)) {
65 $class = self::getClassByInstance($field, self::$record_field_class_patter);
66 $instance =
new $class($record, $field);
68 if (!$instance->getFieldRepresentation()) {
69 $instance->setFieldRepresentation(self::getFieldRepresentationInstance($field));
72 if (!$instance->getRecordRepresentation()) {
73 $instance->setRecordRepresentation(self::getRecordRepresentationInstance($instance));
75 self::$record_field_cache[$field->
getId()][$record->
getId()] = $instance;
Class ilDclBaseFieldModel.
◆ getRecordModelInstance()
static ilDclFieldFactory::getRecordModelInstance |
( |
|
$record_id | ) |
|
|
static |
◆ getRecordRepresentationInstance()
◆ parseDatatypeTitle()
static ilDclFieldFactory::parseDatatypeTitle |
( |
|
$title | ) |
|
|
static |
Parse string to FieldClass format Replaces _ with camelcase-notation.
- Parameters
-
- Returns
- string
Definition at line 400 of file class.ilDclFieldFactory.php.
References $title.
402 $parts = explode(
"_",
$title);
403 $func =
function ($value) {
404 return ucfirst($value);
407 $parts = array_map($func, $parts);
408 $title = implode(
"", $parts);
◆ $class_path_cache
ilDclFieldFactory::$class_path_cache = array() |
|
staticprotected |
◆ $default_prefix
ilDclFieldFactory::$default_prefix = "ilDcl" |
|
static |
◆ $field_base_path_patter
ilDclFieldFactory::$field_base_path_patter = "./Modules/DataCollection/classes/Fields/%s/" |
|
static |
◆ $field_class_cache
ilDclFieldFactory::$field_class_cache = array() |
|
staticprotected |
◆ $field_class_patter
ilDclFieldFactory::$field_class_patter = "%sFieldModel" |
|
static |
◆ $field_model_cache
ilDclFieldFactory::$field_model_cache = array() |
|
staticprotected |
◆ $field_representation_cache
ilDclFieldFactory::$field_representation_cache = array() |
|
staticprotected |
◆ $field_representation_class_pattern
ilDclFieldFactory::$field_representation_class_pattern = "%sFieldRepresentation" |
|
static |
◆ $field_type_cache
ilDclFieldFactory::$field_type_cache = array() |
|
staticprotected |
◆ $record_class_patter
ilDclFieldFactory::$record_class_patter = "%sRecordModel" |
|
static |
◆ $record_field_cache
ilDclFieldFactory::$record_field_cache = array() |
|
staticprotected |
◆ $record_field_class_patter
ilDclFieldFactory::$record_field_class_patter = "%sRecordFieldModel" |
|
static |
◆ $record_representation_cache
ilDclFieldFactory::$record_representation_cache = array() |
|
staticprotected |
◆ $record_representation_class_pattern
ilDclFieldFactory::$record_representation_class_pattern = "%sRecordRepresentation" |
|
static |
The documentation for this class was generated from the following file: