Fix use of extrafield of type link with CommonObjectLine (#29957)

* define default getNomUrl() in CommonObjectLine class

* Fix mistakes (pre-commit...) and precise function description

* Fix CommonObjectLine::getNomUrl to be useable with existing

* Update commonobjectline.class.php

* Update commonobjectline.class.php

* Update commonobjectline.class.php

---------

Co-authored-by: Laurent Destailleur <eldy@destailleur.fr>
This commit is contained in:
Mathieu Moulin 2024-11-04 23:52:10 +01:00 committed by GitHub
parent 1857b22aed
commit f2b33ffd55
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -330,4 +330,25 @@ abstract class CommonObjectLine extends CommonObject
{
return -1; // NOK because nothing done.
}
/**
* Return clicable link of object line (with eventually picto)
* May (should) also return information about the associated "parent" object.
* To overload
*
* @param int $withpicto Add picto into link
* @return string String with URL
*/
public function getNomUrl($withpicto = 0)
{
$parent_element_properties = getElementProperties($this->parent_element);
$parent_classname = $parent_element_properties['classname'];
$parent_element = new $parent_classname($this->db);
$parentattribute = $this->fk_parent_attribute;
if ($parentattribute) {
$parent_element->fetch($this->$parentattribute);
}
return $parent_element->getNomUrl($withpicto).' - Line #'.$this->id;
}
}