From cd969449f23acd0ae78170faf99dd0d2c22421c8 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Thu, 24 Mar 2022 12:07:04 +0100 Subject: [PATCH] Replaced duplicated code with extends of CommonObjectLine --- .../class/expensereport.class.php | 38 +------------------ 1 file changed, 2 insertions(+), 36 deletions(-) diff --git a/htdocs/expensereport/class/expensereport.class.php b/htdocs/expensereport/class/expensereport.class.php index b85691c586d..f2f0b7dbf0d 100644 --- a/htdocs/expensereport/class/expensereport.class.php +++ b/htdocs/expensereport/class/expensereport.class.php @@ -26,6 +26,7 @@ * \brief File to manage Expense Reports */ require_once DOL_DOCUMENT_ROOT.'/core/class/commonobject.class.php'; +require_once DOL_DOCUMENT_ROOT.'/core/class/commonobjectline.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport_ik.class.php'; require_once DOL_DOCUMENT_ROOT.'/expensereport/class/expensereport_rule.class.php'; @@ -2545,7 +2546,7 @@ class ExpenseReport extends CommonObject /** * Class of expense report details lines */ -class ExpenseReportLine +class ExpenseReportLine extends CommonObjectLine { /** * @var DoliDB Database handler. @@ -2919,39 +2920,4 @@ class ExpenseReportLine return -2; } } - - // phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps - /** - * Call trigger based on this instance. - * Some context information may also be provided into array property this->context. - * NB: Error from trigger are stacked in interface->errors - * NB2: If return code of triggers are < 0, action calling trigger should cancel all transaction. - * - * @param string $triggerName trigger's name to execute - * @param User $user Object user - * @return int Result of run_triggers - */ - public function call_trigger($triggerName, $user) - { - // phpcs:enable - global $langs, $conf; - - if (!is_object($langs)) { // If lang was not defined, we set it. It is required by run_triggers. - include_once DOL_DOCUMENT_ROOT.'/core/class/translate.class.php'; - $langs = new Translate('', $conf); - } - - include_once DOL_DOCUMENT_ROOT.'/core/class/interfaces.class.php'; - $interface = new Interfaces($this->db); - $result = $interface->run_triggers($triggerName, $this, $user, $langs, $conf); - - if ($result < 0) { - if (!empty($this->errors)) { - $this->errors = array_unique(array_merge($this->errors, $interface->errors)); // We use array_unique because when a trigger call another trigger on same object, this->errors is added twice. - } else { - $this->errors = $interface->errors; - } - } - return $result; - } }