mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-02-06 15:14:58 +00:00
add method inList()
This commit is contained in:
parent
9bc7b11605
commit
3f46cbad5b
|
@ -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.
|
||||
*
|
||||
|
|
Loading…
Reference in New Issue
Block a user