add method inList()

This commit is contained in:
Uwe Steinmann 2015-03-17 17:45:12 +01:00
parent 9bc7b11605
commit 3f46cbad5b

View File

@ -167,6 +167,25 @@ class SeedDMS_Core_DMS {
return true;
} /* }}} */
/**
* Checks if a list of objects contains a single object
*
* The regular php check done by '==' compares all attributes of
* two objects, which isn't required. The method will first check
* if the objects are instances of the same class.
*
* @param object $object1 object to look for (needle)
* @param array $list list of objects (haystack)
* @return boolean true if object was found, otherwise false
*/
static function inList($object, $list) { /* {{{ */
foreach($list as $item) {
if(get_class($item) == get_class($object) && $item->getID() == $object->getID())
return true;
}
return false;
} /* }}} */
/**
* Filter objects out which are not accessible in a given mode by a user.
*