From b25c75c87de0c4cb97ebfdeb116cf6b28c982b82 Mon Sep 17 00:00:00 2001 From: Laurent Destailleur Date: Tue, 5 Nov 2024 14:52:59 +0100 Subject: [PATCH] Clean code --- htdocs/core/class/commonobjectline.class.php | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/htdocs/core/class/commonobjectline.class.php b/htdocs/core/class/commonobjectline.class.php index a44d2bd2c12..ef3b9359a70 100644 --- a/htdocs/core/class/commonobjectline.class.php +++ b/htdocs/core/class/commonobjectline.class.php @@ -341,16 +341,23 @@ abstract class CommonObjectLine extends CommonObject */ public function getNomUrl($withpicto = 0) { + $parentattribute = $this->fk_parent_attribute; + + /* + if ($parentattribute) { + return 'Parent #'.$this->$parentattribute.' - Line #'.$this->id; + } else { + return 'Line #'.$this->id; + } + */ + $parent_element_properties = getElementProperties($this->parent_element); $parent_classname = $parent_element_properties['classname']; - - // TODO Avoid a fetch inside a getNomUrl $parent_element = new $parent_classname($this->db); - $parentattribute = $this->fk_parent_attribute; if ($parentattribute && method_exists($parent_element, 'fetch')) { - $parent_element->fetch($this->$parentattribute); + $parent_element->fetch($this->$parentattribute); /* @phpstan-ignore-line */ } - return $parent_element->getNomUrl($withpicto).' - Line #'.$this->id; + return $parent_element->getNomUrl($withpicto).' - Line #'.$this->id; /* @phpstan-ignore-line */ } }