mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
Remove relation to comments (Fixes #76)
This commit is contained in:
parent
5a8de05ea7
commit
5cfa476264
@ -28,8 +28,4 @@
|
|||||||
|
|
||||||
if(class_exists('SiteTree') && !Commenting::has_commenting('SiteTree')) {
|
if(class_exists('SiteTree') && !Commenting::has_commenting('SiteTree')) {
|
||||||
Commenting::add('SiteTree');
|
Commenting::add('SiteTree');
|
||||||
}
|
|
||||||
|
|
||||||
if(class_exists('ContentController')) {
|
|
||||||
ContentController::add_extension('ContentControllerCommentsExtension');
|
|
||||||
}
|
}
|
@ -8,13 +8,8 @@
|
|||||||
|
|
||||||
class CommentsExtension extends DataExtension {
|
class CommentsExtension extends DataExtension {
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds a relationship between this {@link DataObject} and its
|
|
||||||
* {@link Comment} objects. If the owner class is a sitetree class
|
|
||||||
* it also enables a checkbox allowing comments to be turned off and off
|
|
||||||
*/
|
|
||||||
public static function get_extra_config($class, $extension, $args = null) {
|
public static function get_extra_config($class, $extension, $args = null) {
|
||||||
$config = array('has_many' => array('Comments' => 'Comment'));
|
$config = array();
|
||||||
|
|
||||||
// if it is attached to the SiteTree then we need to add ProvideComments
|
// if it is attached to the SiteTree then we need to add ProvideComments
|
||||||
if(is_subclass_of($class, 'SiteTree') || $class == 'SiteTree') {
|
if(is_subclass_of($class, 'SiteTree') || $class == 'SiteTree') {
|
||||||
|
@ -1,11 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @package comments
|
|
||||||
*/
|
|
||||||
class ContentControllerCommentsExtension extends Extension {
|
|
||||||
|
|
||||||
public function Comments() {
|
|
||||||
return $this->owner->dataRecord->getComments();
|
|
||||||
}
|
|
||||||
}
|
|
@ -26,14 +26,14 @@ class CommentingControllerTests extends FunctionalTest {
|
|||||||
$this->assertEquals(10, substr_count($response->getBody(), "<item>"), "10 approved, non spam comments on page 1");
|
$this->assertEquals(10, substr_count($response->getBody(), "<item>"), "10 approved, non spam comments on page 1");
|
||||||
|
|
||||||
$response = $this->get('CommentingController/rss?start=10');
|
$response = $this->get('CommentingController/rss?start=10');
|
||||||
$this->assertEquals(3, substr_count($response->getBody(), "<item>"), "3 approved, non spam comments on page 2");
|
$this->assertEquals(4, substr_count($response->getBody(), "<item>"), "3 approved, non spam comments on page 2");
|
||||||
|
|
||||||
// all comments on a type
|
// all comments on a type
|
||||||
$response = $this->get('CommentingController/rss/CommentableItem');
|
$response = $this->get('CommentingController/rss/CommentableItem');
|
||||||
$this->assertEquals(10, substr_count($response->getBody(), "<item>"));
|
$this->assertEquals(10, substr_count($response->getBody(), "<item>"));
|
||||||
|
|
||||||
$response = $this->get('CommentingController/rss/CommentableItem?start=10');
|
$response = $this->get('CommentingController/rss/CommentableItem?start=10');
|
||||||
$this->assertEquals(3, substr_count($response->getBody(), "<item>"), "3 approved, non spam comments on page 2");
|
$this->assertEquals(4, substr_count($response->getBody(), "<item>"), "3 approved, non spam comments on page 2");
|
||||||
|
|
||||||
// specific page
|
// specific page
|
||||||
$response = $this->get('CommentingController/rss/CommentableItem/'.$item->ID);
|
$response = $this->get('CommentingController/rss/CommentableItem/'.$item->ID);
|
||||||
|
Loading…
Reference in New Issue
Block a user