Handle when extension has been removed from object

When in the admin panel, if parent has been removing from commenting then it won't have the commenting extension attached.
This commit is contained in:
Will Rossiter 2015-11-16 15:35:51 +13:00
parent 018881c345
commit ac92dbb515

View File

@ -202,15 +202,17 @@ class Comment extends DataObject {
public function getOption($key) {
// If possible use the current record
$record = $this->getParent();
if(!$record && $this->BaseClass) {
// Otherwise a singleton of that record
$record = singleton($this->BaseClass);
} elseif(!$record) {
}
else if(!$record) {
// Otherwise just use the default options
$record = singleton('CommentsExtension');
}
return $record->getCommentsOption($key);
return ($record->hasMethod('getCommentsOption')) ? $record->getCommentsOption($key) : null;
}
/**