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:
Will Rossiter 2013-11-28 20:46:14 +13:00
parent c3d6d08348
commit 877537c284
3 changed files with 17 additions and 2 deletions

View File

@ -29,3 +29,7 @@
if(class_exists('SiteTree') && !Commenting::has_commenting('SiteTree')) {
Commenting::add('SiteTree');
}
if(class_exists('ContentController')) {
ContentController::add_extension('ContentControllerCommentsExtension');
}

View File

@ -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()
)));
}

View File

@ -0,0 +1,11 @@
<?php
/**
* @package comments
*/
class ContentControllerCommentsExtension extends Extension {
public function Comments() {
return $this->owner->dataRecord->getComments();
}
}