Test Failed
Branch develop (7f369c)
by Nicolas
04:26
created

CommentsDeleteController::__invoke()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Controller\Api;
4
5
use App\Entity\Comment;
6
use Doctrine\ORM\EntityManagerInterface;
7
use FOS\RestBundle\Controller\Annotations\View;
8
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
9
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
10
use Symfony\Component\Routing\Annotation\Route;
11
12
/**
13
 * CommentsDeleteController.
14
 *
15
 * @Route("/api/articles/{slug}/comments/{id}", name="api_comments_delete")
16
 * @Method("DELETE")
17
 * @View(statusCode=204)
18
 * @IsGranted("OWNER", subject="comment")
19
 */
20
class CommentsDeleteController
21
{
22
    /**
23
     * @var EntityManagerInterface
24
     */
25
    private $manager;
26
27
    /**
28
     * @param EntityManagerInterface $manager
29
     */
30
    public function __construct(EntityManagerInterface $manager)
31
    {
32
        $this->manager = $manager;
33
    }
34
35
    /**
36
     * @param Comment $comment
37
     */
38
    public function __invoke(Comment $comment)
39
    {
40
        $this->manager->remove($comment);
41
        $this->manager->flush();
42
    }
43
}
44