Rename build_path_from_id_categ into buildPathFromId and set it private

This commit is contained in:
Laurent Destailleur 2022-04-06 13:29:52 +02:00
parent a0cb04bafc
commit 370965a0bb
3 changed files with 15 additions and 18 deletions

View File

@ -32,6 +32,7 @@ Following changes may create regressions for some external modules, but were nec
* verifCond('stringtoevaluate') now return false when string contains a bad syntax content instead of true. * verifCond('stringtoevaluate') now return false when string contains a bad syntax content instead of true.
* The deprecated method thirdparty_doc_create() has been removed. You can use the generateDocument() instead. * The deprecated method thirdparty_doc_create() has been removed. You can use the generateDocument() instead.
* All triggers with a name XXX_UPDATE have been rename with name XXX_MODIFY for code consistency purpose. * All triggers with a name XXX_UPDATE have been rename with name XXX_MODIFY for code consistency purpose.
* Rename build_path_from_id_categ() into buildPathFromId() and set method to private
***** ChangeLog for 15.0.1 compared to 15.0.0 ***** ***** ChangeLog for 15.0.1 compared to 15.0.0 *****

View File

@ -1141,10 +1141,10 @@ class Categorie extends CommonObject
} }
// We add the fullpath property to each elements of first level (no parent exists) // We add the fullpath property to each elements of first level (no parent exists)
dol_syslog(get_class($this)."::get_full_arbo call to build_path_from_id_categ", LOG_DEBUG); dol_syslog(get_class($this)."::get_full_arbo call to buildPathFromId", LOG_DEBUG);
foreach ($this->cats as $key => $val) { foreach ($this->cats as $key => $val) {
//print 'key='.$key.'<br>'."\n"; //print 'key='.$key.'<br>'."\n";
$this->build_path_from_id_categ($key, 0); // Process a branch from the root category key (this category has no parent) $this->buildPathFromId($key, 0); // Process a branch from the root category key (this category has no parent)
} }
// Include or exclude leaf including $markafterid from tree // Include or exclude leaf including $markafterid from tree
@ -1174,7 +1174,6 @@ class Categorie extends CommonObject
return $this->cats; return $this->cats;
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* For category id_categ and its childs available in this->cats, define property fullpath and fulllabel. * For category id_categ and its childs available in this->cats, define property fullpath and fulllabel.
* It is called by get_full_arbo() * It is called by get_full_arbo()
@ -1185,19 +1184,18 @@ class Categorie extends CommonObject
* @return void * @return void
* @see get_full_arbo() * @see get_full_arbo()
*/ */
public function build_path_from_id_categ($id_categ, $protection = 1000) private function buildPathFromId($id_categ, $protection = 1000)
{ {
// phpcs:enable //dol_syslog(get_class($this)."::buildPathFromId id_categ=".$id_categ." protection=".$protection, LOG_DEBUG);
dol_syslog(get_class($this)."::build_path_from_id_categ id_categ=".$id_categ." protection=".$protection, LOG_DEBUG);
if (!empty($this->cats[$id_categ]['fullpath'])) { if (!empty($this->cats[$id_categ]['fullpath'])) {
// Already defined // Already defined
dol_syslog(get_class($this)."::build_path_from_id_categ fullpath and fulllabel already defined", LOG_WARNING); dol_syslog(get_class($this)."::buildPathFromId fullpath and fulllabel already defined", LOG_WARNING);
return; return;
} }
// First build full array $motherof // First build full array $motherof
//$this->load_motherof(); // Disabled because already done by caller of build_path_from_id_categ //$this->load_motherof(); // Disabled because already done by caller of buildPathFromId
// $this->cats[$id_categ] is supposed to be already an array. We just want to complete it with property fullpath and fulllabel // $this->cats[$id_categ] is supposed to be already an array. We just want to complete it with property fullpath and fulllabel

View File

@ -627,10 +627,10 @@ class EcmDirectory extends CommonObject
* date_c Date creation * date_c Date creation
* fk_user_c User creation * fk_user_c User creation
* login_c Login creation * login_c Login creation
* fullpath Full path of id (Added by build_path_from_id_categ call) * fullpath Full path of id (Added by buildPathFromId call)
* fullrelativename Full path name (Added by build_path_from_id_categ call) * fullrelativename Full path name (Added by buildPathFromId call)
* fulllabel Full label (Added by build_path_from_id_categ call) * fulllabel Full label (Added by buildPathFromId call)
* level Level of line (Added by build_path_from_id_categ call) * level Level of line (Added by buildPathFromId call)
* *
* @param int $force Force reload of full arbo even if already loaded in cache $this->cats * @param int $force Force reload of full arbo even if already loaded in cache $this->cats
* @return array Tableau de array * @return array Tableau de array
@ -698,10 +698,10 @@ class EcmDirectory extends CommonObject
// We add properties fullxxx to all elements // We add properties fullxxx to all elements
foreach ($this->cats as $key => $val) { foreach ($this->cats as $key => $val) {
if (isset($motherof[$key])) { if (isset($this->motherof[$key])) {
continue; continue;
} }
$this->build_path_from_id_categ($key, 0); $this->buildPathFromId($key, 0);
} }
$this->cats = dol_sort_array($this->cats, 'fulllabel', 'asc', true, false); $this->cats = dol_sort_array($this->cats, 'fulllabel', 'asc', true, false);
@ -710,7 +710,6 @@ class EcmDirectory extends CommonObject
return $this->cats; return $this->cats;
} }
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
/** /**
* Define properties fullpath, fullrelativename, fulllabel of a directory of array this->cats and all its childs. * Define properties fullpath, fullrelativename, fulllabel of a directory of array this->cats and all its childs.
* Separator between directories is always '/', whatever is OS. * Separator between directories is always '/', whatever is OS.
@ -719,9 +718,8 @@ class EcmDirectory extends CommonObject
* @param int $protection Deep counter to avoid infinite loop * @param int $protection Deep counter to avoid infinite loop
* @return void * @return void
*/ */
public function build_path_from_id_categ($id_categ, $protection = 0) private function buildPathFromId($id_categ, $protection = 0)
{ {
// phpcs:enable
// Define fullpath // Define fullpath
if (!empty($this->cats[$id_categ]['id_mere'])) { if (!empty($this->cats[$id_categ]['id_mere'])) {
$this->cats[$id_categ]['fullpath'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fullpath']; $this->cats[$id_categ]['fullpath'] = $this->cats[$this->cats[$id_categ]['id_mere']]['fullpath'];
@ -745,7 +743,7 @@ class EcmDirectory extends CommonObject
} }
if (isset($this->cats[$id_categ]['id_children']) && is_array($this->cats[$id_categ]['id_children'])) { if (isset($this->cats[$id_categ]['id_children']) && is_array($this->cats[$id_categ]['id_children'])) {
foreach ($this->cats[$id_categ]['id_children'] as $key => $val) { foreach ($this->cats[$id_categ]['id_children'] as $key => $val) {
$this->build_path_from_id_categ($val, $protection); $this->buildPathFromId($val, $protection);
} }
} }
} }