mirror of
https://github.com/silverstripe/silverstripe-comments
synced 2024-10-22 11:05:49 +02:00
Fixing CommentsExtension to use the correct Config API for adding statics
This commit is contained in:
parent
4a691cc5b6
commit
a47efa518d
@ -12,33 +12,20 @@ class CommentsExtension extends DataExtension {
|
|||||||
* Adds a relationship between this {@link DataObject} and its
|
* Adds a relationship between this {@link DataObject} and its
|
||||||
* {@link Comment} objects. If the owner class is a sitetree class
|
* {@link Comment} objects. If the owner class is a sitetree class
|
||||||
* it also enables a checkbox allowing comments to be turned off and off
|
* it also enables a checkbox allowing comments to be turned off and off
|
||||||
*
|
|
||||||
* @return array
|
|
||||||
*/
|
*/
|
||||||
public function extraStatics($class = null, $extension = null) {
|
public static function add_to_class($class, $extensionClass, $args = null) {
|
||||||
$fields = array();
|
Config::inst()->update($class, 'has_many', array(
|
||||||
|
'Comments' => 'Comment'
|
||||||
$relationships = array(
|
));
|
||||||
'has_many' => array(
|
|
||||||
'Comments' => 'Comment'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
// 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
|
||||||
// cannot check $this->owner as this in intialised via call_user_func
|
if(is_subclass_of($class, 'SiteTree') || $class == 'SiteTree') {
|
||||||
$args = func_get_args();
|
Config::inst()->update($class, 'db', array(
|
||||||
|
'ProvideComments' => 'Boolean'
|
||||||
if($args && ($owner = array_shift($args))) {
|
));
|
||||||
if(is_subclass_of($owner, 'SiteTree') || $owner == "SiteTree") {
|
|
||||||
$fields = array(
|
|
||||||
'db' => array(
|
|
||||||
'ProvideComments' => 'Boolean'
|
|
||||||
)
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return array_merge($fields, $relationships);
|
parent::add_to_class($class, $extensionClass, $args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user