You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
37 lines
885 B
37 lines
885 B
7 years ago
|
<?php
|
||
|
|
||
|
namespace common\modules\blog\services;
|
||
|
|
||
|
use common\modules\blog\forms\BlogCommentEditForm;
|
||
|
use common\modules\blog\repositories\BlogRepository;
|
||
|
|
||
|
class BlogCommentManageService
|
||
|
{
|
||
|
private $posts;
|
||
|
|
||
|
public function __construct(BlogRepository $posts)
|
||
|
{
|
||
|
$this->posts = $posts;
|
||
|
}
|
||
|
|
||
|
public function edit($postId, $id, BlogCommentEditForm $form): void
|
||
|
{
|
||
|
$post = $this->posts->get($postId);
|
||
|
$post->editComment($id, $form->parentId, $form->text);
|
||
|
$this->posts->save($post);
|
||
|
}
|
||
|
|
||
|
public function activate($postId, $id): void
|
||
|
{
|
||
|
$post = $this->posts->get($postId);
|
||
|
$post->activateComment($id);
|
||
|
$this->posts->save($post);
|
||
|
}
|
||
|
|
||
|
public function remove($postId, $id): void
|
||
|
{
|
||
|
$post = $this->posts->get($postId);
|
||
|
$post->removeComment($id);
|
||
|
$this->posts->save($post);
|
||
|
}
|
||
|
}
|