mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
Merge pull request #97 from arambalakjian/pulls/controller-instantiation
API Adding config option for enabling comments to be added to SiteTree
This commit is contained in:
commit
882c65fdd5
@ -26,6 +26,6 @@
|
|||||||
* consult the Commenting class.
|
* consult the Commenting class.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
if(class_exists('SiteTree') && !Commenting::has_commenting('SiteTree')) {
|
if(Config::inst()->get('Commenting', 'sitetree_comments') && class_exists('SiteTree') && !Commenting::has_commenting('SiteTree')) {
|
||||||
Commenting::add('SiteTree');
|
Commenting::add('SiteTree');
|
||||||
}
|
}
|
@ -19,6 +19,12 @@ class Commenting {
|
|||||||
*/
|
*/
|
||||||
private static $enabled_classes = array();
|
private static $enabled_classes = array();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @config
|
||||||
|
* @var bool Whether to enable commenting on SiteTree objects by default
|
||||||
|
*/
|
||||||
|
private static $sitetree_comments = true;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @var array default configuration values
|
* @var array default configuration values
|
||||||
*/
|
*/
|
||||||
|
@ -108,7 +108,7 @@ class CommentsExtension extends DataExtension {
|
|||||||
// do not include the comments on pages which don't have id's such as security pages
|
// do not include the comments on pages which don't have id's such as security pages
|
||||||
if($this->owner->ID < 0) return false;
|
if($this->owner->ID < 0) return false;
|
||||||
|
|
||||||
$controller = new CommentingController();
|
$controller = CommentingController::create();
|
||||||
$controller->setOwnerRecord($this->owner);
|
$controller->setOwnerRecord($this->owner);
|
||||||
$controller->setBaseClass($this->ownerBaseClass);
|
$controller->setBaseClass($this->ownerBaseClass);
|
||||||
$controller->setOwnerController(Controller::curr());
|
$controller->setOwnerController(Controller::curr());
|
||||||
|
Loading…
Reference in New Issue
Block a user