mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 12:05:37 +00:00
#2200 - Allowed subclasses in ComponentSet::add/remove
git-svn-id: svn://svn.silverstripe.com/silverstripe/open/modules/sapphire/trunk@49708 467b73ca-7a2a-4603-9d3b-597d59a354a9
This commit is contained in:
parent
1273671cdf
commit
5b1436eaa4
@ -89,9 +89,8 @@ class ComponentSet extends DataObjectSet {
|
||||
}
|
||||
|
||||
if(is_object($item)) {
|
||||
// TODO Should this allow subclasses?
|
||||
if($item->class != $this->childClass) {
|
||||
user_error("ComponentSet::add() Tried to add an '{$item->class}' object, but '{$this->childClass}' expected", E_USER_ERROR);
|
||||
if(!is_a($item, $this->childClass)) {
|
||||
user_error("ComponentSet::add() Tried to add an '{$item->class}' object, but a '{$this->childClass}' object expected", E_USER_ERROR);
|
||||
}
|
||||
} else {
|
||||
$id = $item;
|
||||
@ -196,8 +195,8 @@ class ComponentSet extends DataObjectSet {
|
||||
*/
|
||||
function remove($item) {
|
||||
if(is_object($item)) {
|
||||
if($item->class != $this->childClass && !is_subclass_of($item, $this->childClass)) {
|
||||
user_error("ComponentSet::remove() Tried to remove an '{$item->class}' object, but '{$this->childClass}' expected", E_USER_ERROR);
|
||||
if(!is_a($item, $this->childClass)) {
|
||||
user_error("ComponentSet::remove() Tried to remove an '{$item->class}' object, but a '{$this->childClass}' object expected", E_USER_ERROR);
|
||||
}
|
||||
} else {
|
||||
$item = DataObject::get_by_id($this->childClass, $item);
|
||||
|
Loading…
x
Reference in New Issue
Block a user