N°2683 - EnhancedSLAComputation: use common extension mechanism (#744)

This commit is contained in:
Anne-Catherine
2025-10-02 15:40:16 +02:00
committed by GitHub
parent fbf3dd8cf7
commit 8f038d2f95
24 changed files with 40 additions and 572 deletions

View File

@@ -4927,7 +4927,7 @@ abstract class DBObject implements iDisplay
{
if (is_null($sWorkingTimeComputer))
{
$sWorkingTimeComputer = class_exists('SLAComputation') ? 'SLAComputation' : 'DefaultWorkingTimeComputer';
$sWorkingTimeComputer = MetaModel::GetWorkingTime(get_class($this));
}
$oComputer = new $sWorkingTimeComputer();
$aCallSpec = array($oComputer, 'GetOpenDuration');

View File

@@ -399,6 +399,32 @@ abstract class MetaModel
return null;
}
final public static function GetDefaultWorkingTime()
{
return 'DefaultWorkingTimeComputer';
}
/**
* @param string $sClass
*
* @return string the working time class
* @throws \CoreException
* @since 3.3.0
*/
final public static function GetWorkingTime($sClass)
{
self::_check_subclass($sClass);
if (array_key_exists('working_time', self::$m_aClassParams[$sClass])) {
return self::$m_aClassParams[$sClass]['working_time'];
} else {
$sParentClass = self::GetParentPersistentClass($sClass);
if (strlen($sParentClass) > 0) {
return self::GetWorkingTime($sParentClass);
}
}
return self::GetDefaultWorkingTime();
}
/**
* @param string $sClass
*

View File

@@ -289,7 +289,7 @@ class ormStopWatch
$sWorkingTimeComputer = $oAttDef->Get('working_time_computing');
if ($sWorkingTimeComputer == '')
{
$sWorkingTimeComputer = class_exists('SLAComputation') ? 'SLAComputation' : 'DefaultWorkingTimeComputer';
$sWorkingTimeComputer = MetaModel::GetWorkingTime(get_class($oObject));
}
$oComputer = new $sWorkingTimeComputer();
$aCallSpec = array($oComputer, 'GetDeadline');
@@ -318,7 +318,7 @@ class ormStopWatch
$sWorkingTimeComputer = $oAttDef->Get('working_time_computing');
if ($sWorkingTimeComputer == '')
{
$sWorkingTimeComputer = class_exists('SLAComputation') ? 'SLAComputation' : 'DefaultWorkingTimeComputer';
$sWorkingTimeComputer = MetaModel::GetWorkingTime(get_class($oObject));
}
$oComputer = new $sWorkingTimeComputer();
$aCallSpec = array($oComputer, 'GetOpenDuration');