mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
FIX: resolve Controller not failing over to an extension method (Fixes #76)
Currently an issue exists that when a controller calls a method which exists on an extension (i.e Comments()) it incorrectly classed as a relation instead of a method resulting in a SQL error. This patch works around that issue by directly invoking the method.
This commit is contained in:
parent
c3d6d08348
commit
877537c284
@ -29,3 +29,7 @@
|
||||
if(class_exists('SiteTree') && !Commenting::has_commenting('SiteTree')) {
|
||||
Commenting::add('SiteTree');
|
||||
}
|
||||
|
||||
if(class_exists('ContentController')) {
|
||||
ContentController::add_extension('ContentControllerCommentsExtension');
|
||||
}
|
@ -47,7 +47,7 @@ class CommentsExtension extends DataExtension {
|
||||
*
|
||||
* @return PaginatedList
|
||||
*/
|
||||
public function Comments() {
|
||||
public function getComments() {
|
||||
$order = Commenting::get_config_value($this->ownerBaseClass, 'order_comments_by');
|
||||
|
||||
$list = Comment::get()->filter(array(
|
||||
@ -132,7 +132,7 @@ class CommentsExtension extends DataExtension {
|
||||
'Parent' => $this->owner,
|
||||
'AddCommentForm' => $form,
|
||||
'ModeratedSubmitted' => $moderatedSubmitted,
|
||||
'Comments' => $this->Comments()
|
||||
'Comments' => $this->getComments()
|
||||
)));
|
||||
}
|
||||
|
||||
|
11
code/extensions/ContentControllerCommentsExtension.php
Normal file
11
code/extensions/ContentControllerCommentsExtension.php
Normal file
@ -0,0 +1,11 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @package comments
|
||||
*/
|
||||
class ContentControllerCommentsExtension extends Extension {
|
||||
|
||||
public function Comments() {
|
||||
return $this->owner->dataRecord->getComments();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user