*/
private $valueInstance = null;
+ /**
+ * Extra instance to the class which provides field values
+ */
+ private $extraInstance = null;
+
/**
* Rendered content created by the helper class
*/
private $totalCounter = 0;
// Exception constants
- const EXCEPTION_XML_PARSER_ERROR = 0x1e0;
- const EXCEPTION_XML_NODE_UNKNOWN = 0x1e1;
- const EXCEPTION_XML_NODE_MISMATCH = 0x1e2;
const EXCEPTION_GROUP_NOT_OPENED = 0x1e3;
const EXCEPTION_GROUP_ALREADY_FOUND = 0x1e4;
const EXCEPTION_SUB_GROUP_ALREADY_FOUND = 0x1e5;
public function assignFieldWithFilter ($fieldName, $filterMethod) {
// Get the value
$fieldValue = $this->getValueField($fieldName);
+ //* DEBUG: */ $this->debugOutput($fieldName.'='.$fieldValue);
// Now filter it through the value through the filter method
$filteredValue = call_user_func_array(array($this, 'doFilter' . $this->convertToClassName($filterMethod)), array($fieldValue));
* @throws NullPointerException If recovery of requested value instance failed
*/
public function prefetchValueInstance ($registryKey, $extraKey = null) {
+ //* DEBUG: */ $this->debugOutput('O:'.$registryKey.'/'.$extraKey);
try {
// Get the required instance
$this->valueInstance = Registry::getRegistry()->getInstance($registryKey);
} catch (NullPointerException $e) {
// Not set in registry
// @TODO Try to log it here
+ //* DEBUG: */ $this->debugOutput($registryKey.'=NULL!');
}
- // Is the value instance valid?
- if (is_null($this->valueInstance)) {
- // Try to create it "from scratch", by first init extra instance
- $extraInstance = null;
-
- // Shall we get an extra instance?
- if (!is_null($extraKey)) {
+ // Shall we get an extra instance?
+ if (!is_null($extraKey)) {
+ try {
// Get the extra instance.
- $extraInstance = Registry::getRegistry()->getInstance($extraKey);
- } // END - if
+ $this->extraInstance = Registry::getRegistry()->getInstance($extraKey);
+ } catch (NullPointerException $e) {
+ // Try to create it
+ $this->extraInstance = ObjectFactory::createObjectByConfiguredName($extraKey . '_class', array($this->valueInstance));
+ }
+ //* DEBUG: */ $this->debugOutput($extraKey.'='.$this->extraInstance.' - EXTRA!');
+ } // END - if
+ // Is the value instance valid?
+ if (is_null($this->valueInstance)) {
try {
// Get the requested instance
- $this->valueInstance = ObjectFactory::createObjectByConfiguredName($registryKey . '_class', array($extraInstance));
+ $this->valueInstance = ObjectFactory::createObjectByConfiguredName($registryKey . '_class', array($this->extraInstance));
} catch (FrameworkException $e) {
// Okay, nothing found so throw a null pointer exception here
throw new NullPointerException($this, self::EXCEPTION_IS_NULL_POINTER);
// Now "walk" through all groups and sub-groups
for ($idx = 1; $idx <= $this->totalCounter; $idx++) {
- // Is this a group and is it closed?
+ // Is this a sub/group and is it closed?
if ((isset($this->groups[$idx])) && ($this->groups[$this->groups[$idx]]['opened'] === false)) {
// Then add it's content
$groupContent = trim($this->groups[$this->groups[$idx]]['content']);
// Get the field value
$fieldValue = $this->getValueInstance()->getField($fieldName);
+ //* DEBUG: */ $this->debugOutput($fieldName.'[]='.gettype($fieldValue).'('.strlen($fieldValue).')');
+
+ // Is it null?
+ if ((is_null($fieldValue)) && (!is_null($this->extraInstance))) {
+ // So try the extra instance
+ $fieldValue = $this->extraInstance->getField($fieldName);
+ } // END - if
// Return it
return $fieldValue;