ENHANCEMENT Added DataObjectSet->replace()

git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/branches/2.3@69888 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
Ingo Schommer 2009-01-08 03:29:28 +00:00 committed by Sam Minnee
parent 4e11307eae
commit bac6cd00ec

View File

@ -457,6 +457,21 @@ class DataObjectSet extends ViewableData implements IteratorAggregate {
}
}
/**
* Replaces $itemOld with $itemNew
*
* @param DataObject $itemOld
* @param DataObject $itemNew
*/
public function replace($itemOld, $itemNew) {
foreach($this->items as $key => $item) {
if($item === $itemOld) {
$this->items[$key] = $itemNew;
return;
}
}
}
/**
* Merge another set onto the end of this set.
* @param DataObjectSet $anotherSet Set to mege onto this set.