From 5b1436eaa4397c612a654c5e821e529413aebada Mon Sep 17 00:00:00 2001 From: Sam Minnee Date: Mon, 18 Feb 2008 05:19:22 +0000 Subject: [PATCH] #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 --- core/model/ComponentSet.php | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/core/model/ComponentSet.php b/core/model/ComponentSet.php index a8e0278f5..412667880 100755 --- a/core/model/ComponentSet.php +++ b/core/model/ComponentSet.php @@ -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);