mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
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:
parent
018881c345
commit
ac92dbb515
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user