SetLastCommentWhenCommentPosted.php
844 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
<?php
namespace FootyRoom\Core\ForumPost;
use FootyRoom\Queries\PostQuery;
class SetLastCommentWhenCommentPosted
{
/**
* @var \FootyRoom\Queries\PostQuery
*/
protected $postQuery;
/**
* Constructor.
*
* @param \FootyRoom\Queries\PostQuery $postRepo
*/
public function __construct(PostQuery $postQuery)
{
$this->postQuery = $postQuery;
}
/**
* Handler.
*
* @param \FootyRoom\Core\ForumPost\ForumPostCommentPosted $event
*/
public function handle(ForumPostCommentPosted $event)
{
$this->postQuery->updateLastComment(
(int) explode(':', $event->comment->getDiscussionId())[1],
$event->comment->getAuthor()->getUserId(),
$event->comment->getId(),
$event->comment->getDate()
);
}
}