mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
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:
parent
4e11307eae
commit
bac6cd00ec
@ -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.
|
||||
|
Loading…
x
Reference in New Issue
Block a user