Passed
Push — develop ( 743c4e...d8f86b )
by BENARD
08:44
created

ForumController::readForum()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 4
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
1
<?php
2
3
namespace ProjetNormandie\ForumBundle\Controller;
4
5
use Doctrine\DBAL\Exception;
6
use ProjetNormandie\ForumBundle\Service\MarkAsReadService;
7
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
8
use Symfony\Component\HttpFoundation\JsonResponse;
9
use ProjetNormandie\ForumBundle\Entity\Forum;
10
11
/**
12
 * Class ForumController
13
 */
14
class ForumController extends AbstractController
15
{
16
    private MarkAsReadService $markAsReadService;
17
18
    public function __construct(MarkAsReadService $markAsReadService)
19
    {
20
        $this->markAsReadService = $markAsReadService;
21
    }
22
23
    /**
24
     * @return JsonResponse
25
     */
26
    public function readAll(): JsonResponse
27
    {
28
        $this->markAsReadService->readAll();
29
        return new JsonResponse(['sucess' => true]);
30
    }
31
32
33
34
    /**
35
     * @param Forum $forum
36
     * @return JsonResponse
37
     */
38
    public function readForum(Forum $forum): JsonResponse
39
    {
40
        $this->markAsReadService->readForum($forum);
41
        return new JsonResponse(['sucess' => true]);
42
    }
43
}
44