mirror of
https://github.com/Combodo/iTop.git
synced 2026-05-14 04:48:54 +02:00
Add computed tag for attribute computation from OQL Expression
This commit is contained in:
@@ -708,6 +708,8 @@ abstract class DBObject implements iDisplay
|
||||
|
||||
$this->UpdateMetaAttributes(array($sAttCode));
|
||||
|
||||
$this->UpdateDependentComputedAttributes($sAttCode);
|
||||
|
||||
// The object has changed, reset caches
|
||||
$this->m_bCheckStatus = null;
|
||||
|
||||
@@ -6992,5 +6994,23 @@ abstract class DBObject implements iDisplay
|
||||
{
|
||||
return array_key_exists($sSection, $this->aContext);
|
||||
}
|
||||
|
||||
/**
|
||||
* @param string $sAttCode
|
||||
*
|
||||
* @return void
|
||||
* @throws CoreException
|
||||
* @throws OQLException
|
||||
*/
|
||||
private function UpdateDependentComputedAttributes(string $sAttCode): void
|
||||
{
|
||||
foreach (MetaModel::GetDependentAttributes(get_class($this), $sAttCode) as $sCode) {
|
||||
$oAttDef = MetaModel::GetAttributeDef(get_class($this), $sCode);
|
||||
if ($oAttDef->IsComputed()) {
|
||||
$oExpression = Expression::FromOQL($oAttDef->GetParams()['expression']);
|
||||
$this->_Set($sCode, $this->EvaluateExpression($oExpression));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user