Add computed tag for attribute computation from OQL Expression

This commit is contained in:
XavierGR
2025-04-18 08:04:38 +02:00
parent 96382377ee
commit 5ba44a03ea
4 changed files with 58 additions and 3 deletions

View File

@@ -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));
}
}
}
}