mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
FIX Nicer fallback if Parent is not set correctly.
This commit is contained in:
parent
cc0ec9b224
commit
567c2236db
@ -135,9 +135,11 @@ class Comment extends DataObject {
|
|||||||
* @return DataObject
|
* @return DataObject
|
||||||
*/
|
*/
|
||||||
public function getParent() {
|
public function getParent() {
|
||||||
if(!$this->BaseClass) $this->BaseClass = "SiteTree";
|
if(!$this->BaseClass) {
|
||||||
|
$this->BaseClass = "SiteTree";
|
||||||
|
}
|
||||||
|
|
||||||
return DataObject::get_by_id($this->BaseClass, $this->ParentID);
|
return ($this->ParentID) ? DataObject::get_by_id($this->BaseClass, $this->ParentID) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -149,9 +151,9 @@ class Comment extends DataObject {
|
|||||||
public function getParentTitle(){
|
public function getParentTitle(){
|
||||||
$parent = $this->getParent();
|
$parent = $this->getParent();
|
||||||
|
|
||||||
return ($parent->Title) ? $parent->Title : $parent->ClassName . " #" . $parent->ID;
|
return ($parent && $parent->Title) ? $parent->Title : $parent->ClassName . " #" . $parent->ID;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Comment-parent classnames obviousely vary, return the parent classname
|
* Comment-parent classnames obviousely vary, return the parent classname
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user