API Enable comment specific enhancements

If an author creates a comment include a highlight class
This commit is contained in:
Damian Mooyman 2015-04-09 13:50:41 +12:00
parent 78bc202323
commit 5817eea314
3 changed files with 35 additions and 1 deletions

8
_config/comments.yml Normal file
View File

@ -0,0 +1,8 @@
---
Name: blogcommentsconfig
Only:
moduleexists: comments
---
Comment:
extensions:
- BlogCommentExtension

View File

@ -1,3 +1,6 @@
---
Name: blogconfig
---
Member:
extensions:
- BlogMemberExtension

View 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';
}
}
}