mirror of
https://github.com/silverstripe/silverstripe-blog
synced 2024-10-22 11:05:58 +02:00
Merge pull request #176 from tractorcow/pulls/2.0/comments-extension
API Enable comment specific enhancements
This commit is contained in:
commit
32c18515c1
8
_config/comments.yml
Normal file
8
_config/comments.yml
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
---
|
||||||
|
Name: blogcommentsconfig
|
||||||
|
Only:
|
||||||
|
moduleexists: comments
|
||||||
|
---
|
||||||
|
Comment:
|
||||||
|
extensions:
|
||||||
|
- BlogCommentExtension
|
@ -1,3 +1,6 @@
|
|||||||
|
---
|
||||||
|
Name: blogconfig
|
||||||
|
---
|
||||||
Member:
|
Member:
|
||||||
extensions:
|
extensions:
|
||||||
- BlogMemberExtension
|
- BlogMemberExtension
|
23
code/extensions/BlogCommentExtension.php
Normal file
23
code/extensions/BlogCommentExtension.php
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Adds Blog specific behaviour to Comment
|
||||||
|
* Extends {@see Comment}
|
||||||
|
*/
|
||||||
|
class BlogCommentExtension extends DataExtension {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Extra CSS classes for styling different comment types.
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function getExtraClass() {
|
||||||
|
$blogPost = $this->owner->getParent();
|
||||||
|
|
||||||
|
// Make sure we're dealing with a BlogPost.
|
||||||
|
if ( ($blogPost instanceof BlogPost)
|
||||||
|
&& $blogPost->isAuthor($this->owner->Author())
|
||||||
|
) {
|
||||||
|
return 'author-comment';
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user