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

RevertHistoryTrickController   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 26
rs 10
c 0
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A revertHistory() 0 7 1
A __construct() 0 3 1
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
}