add some documentation for isDescendant() and isSubFolder()

This commit is contained in:
Uwe Steinmann 2021-09-24 10:19:31 +02:00
parent 3d7357fca9
commit 3cf58fbc86

View File

@ -390,6 +390,8 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
* to say it differently the passed folder is somewhere below the * to say it differently the passed folder is somewhere below the
* current folder. * current folder.
* *
* This is basically the opposite of {@see SeedDMS_Core_Folder::isDescendant()}
*
* @param SeedDMS_Core_Folder $subfolder folder to be checked if it is * @param SeedDMS_Core_Folder $subfolder folder to be checked if it is
* a subfolder on any level of the current folder * a subfolder on any level of the current folder
* @return bool true if passed folder is a subfolder, otherwise false * @return bool true if passed folder is a subfolder, otherwise false
@ -795,15 +797,22 @@ class SeedDMS_Core_Folder extends SeedDMS_Core_Object {
/** /**
* Check, if this folder is a subfolder of a given folder * Check, if this folder is a subfolder of a given folder
*
* This is basically the opposite of {@see SeedDMS_Core_Folder::isSubFolder()}
* *
* @param object $folder parent folder * @param object $folder parent folder
* @return boolean true if folder is a subfolder * @return boolean true if folder is a subfolder
*/ */
function isDescendant($folder) { /* {{{ */ function isDescendant($folder) { /* {{{ */
/* If the current folder has no parent it cannot be a descendant */
if(!$this->getParent()) if(!$this->getParent())
return false; return false;
/* Check if the passed folder is the parent of the current folder.
* In that case the current folder is a subfolder of the passed folder.
*/
if($this->getParent()->getID() == $folder->getID()) if($this->getParent()->getID() == $folder->getID())
return true; return true;
/* Recursively go up to the root folder */
return $this->getParent()->isDescendant($folder); return $this->getParent()->isDescendant($folder);
} /* }}} */ } /* }}} */