Passed
Push — master ( 786b21...4a8f5f )
by Stone
06:47 queued 42s
created

RevertHistoryTrickController::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 1
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\Controller\Trick\Admin;
4
5
use App\Entity\Trick;
6
use App\History\TrickHistory;
7
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
8
use Symfony\Component\Routing\Annotation\Route;
9
use Sensio\Bundle\FrameworkExtraBundle\Configuration\IsGranted;
10
11
12
/**
13
 * Class RevertHistoryTrickController
14
 * @package App\Controller\Trick\Admin
15
 * @IsGranted("ROLE_ADMIN")
16
 */
17
class RevertHistoryTrickController extends AbstractController
18
{
19
20
    /**
21
     * @var TrickHistory
22
     */
23
    private $trickHistory;
24
25
    public function __construct(TrickHistory $trickHistory)
26
    {
27
        $this->trickHistory = $trickHistory;
28
    }
29
30
    /**
31
     * @param Trick $trick
32
     * @param $historyId
33
     * @return \Symfony\Component\HttpFoundation\RedirectResponse
34
     * @Route("/trick/revert/{id}/{historyId}", name="trick.revert")
35
     */
36
    public function revertHistory(Trick $trick, $historyId)
37
    {
38
        $this->trickHistory->revertToHistory($trick->getId(), $historyId);
39
40
        return $this->redirectToRoute('trick.show', [
41
            'id' => $trick->getId(),
42
            'slug' => $trick->getSlug(),
43
        ]);
44
    }
45
}