Skip to content

Commit b8cfff9

Browse files
author
Marvin Kuhn
committed
added option to add the comments on the top of all comments
1 parent 620f23e commit b8cfff9

File tree

3 files changed

+26
-12
lines changed

3 files changed

+26
-12
lines changed

Classes/Service/CommentService.php

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ class CommentService
2727
*/
2828
protected $contextFactory;
2929

30+
/**
31+
* @Flow\InjectConfiguration(path="addToTop")
32+
* @var ContextFactoryInterface
33+
*/
34+
protected $addCommentToTop;
35+
3036
/**
3137
* @Flow\Inject()
3238
* @var NodeTypeManager
@@ -54,6 +60,11 @@ protected function createNode(NodeInterface $commentCollection, CommentDto $comm
5460
$commentNode->setProperty('createdAt', $comment->getCreatedAt());
5561
$commentNode->setHidden($comment->isHidden());
5662

63+
if ($this->addCommentToTop) {
64+
$firstComment = $commentCollection->getChildNodes(null, 1);
65+
$commentNode->moveBefore($firstComment[0]);
66+
}
67+
5768
return $commentNode;
5869
}
5970

Configuration/Settings.Neos.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
Neos:
2+
Neos:
3+
userInterface:
4+
translation:
5+
autoInclude:
6+
'Breadlesscode.Commentable':
7+
- 'NodeTypes/Collection/*'
8+
- 'NodeTypes/Content/*'
9+
- 'NodeTypes/Mixin/*'
10+
fusion:
11+
autoInclude:
12+
Breadlesscode.Commentable: true

Configuration/Settings.yaml

Lines changed: 3 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,3 @@
1-
Neos:
2-
Neos:
3-
userInterface:
4-
translation:
5-
autoInclude:
6-
'Breadlesscode.Commentable':
7-
- 'NodeTypes/Collection/*'
8-
- 'NodeTypes/Content/*'
9-
- 'NodeTypes/Mixin/*'
10-
fusion:
11-
autoInclude:
12-
Breadlesscode.Commentable: true
1+
Breadlesscode:
2+
Commentable:
3+
addToTop: true

0 commit comments

Comments
 (0)