Better initialization of objects from the "Context" values:

- map the parameters (for example for Provider Contract)
- set the default values when creating a "secondary" object via the (+) button

SVN:trunk[1391]
This commit is contained in:
Denis Flaven
2011-07-31 08:54:59 +00:00
parent ca8ea8dd02
commit 5baa213e6a
3 changed files with 41 additions and 17 deletions

View File

@@ -204,6 +204,35 @@ class ApplicationContext
}
}
/**
* Initializes the given object with the default values provided by the context
*/
public function InitObjectFromContext(DBObject &$oObj)
{
$sClass = get_class($oObj);
foreach($this->GetNames() as $key)
{
$aCallSpec = array($sClass, 'MapContextParam');
if (is_callable($aCallSpec))
{
$sAttCode = call_user_func($aCallSpec, $key); // Returns null when there is no mapping for this parameter
}
if (MetaModel::IsValidAttCode($sClass, $sAttCode))
{
$oAttDef = MetaModel::GetAttributeDef($sClass, $sAttCode);
if ($oAttDef->IsWritable())
{
$value = $this->GetCurrentValue($key, null);
if (!is_null($value))
{
$oObj->Set($sAttCode, $value);
}
}
}
}
}
static $m_sUrlMakerClass = null;
/**