mirror of
https://github.com/Combodo/iTop.git
synced 2026-02-12 23:14:18 +01:00
N°2683 - EnhancedSLAComputation: use common extension mechanism (#744)
This commit is contained in:
@@ -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');
|
||||
|
||||
@@ -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
|
||||
*
|
||||
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user