/** * Reads value of property of item in editor. * * This getter is asking several sources to provide selected property's * value, testing sources in this order: * * # First, property is looked up in a special set of fixed/immutable values. * # Next, current (volatile) input of script is checked to contain some matching value. * # Then all fields of editor are checked for providing some matching value. * # Finally, item in editor is directly requested to provide value. * * @param string $property name of property to fetch * @param boolean $customField true if value is retrieved for custom field (and thus value can't be fetched from model instance obviously) * @param model_editor_element $element optional available for preparing value loaded from database * @return mixed value of fetched property */ public function getValue($property, $customField = false, model_editor_element $element = null) { // 1. try optional set of fixed/immutable properties $fixed = $this->getFixed(); if (is_array($fixed) && array_key_exists($property, $fixed)) { return $fixed[$property]; } // 2. try actual input of current script $input = input::vget($this->propertyToField($property), null); if (!is_null($input)) { return $input; } // 3. try manager for related field of editor foreach ($this->fields as $name => $field) { /** @var model_editor_field $field */ if ($name === $property) { $value = $field->type()->onLoading($this, $this->item, $property, $field); if (!is_null($value)) { return $value; } break; } } // 4. try item in editor if ($this->item && !$customField) { $value = $this->item->__get($property); if ($element) { $value = $element->afterLoading($this, $this->item, $property, $value); } return $value; } // fail ... there is no value for selected property return null; }