Passed
Branch develop (eab57f)
by Stone
15:30 queued 09:17
created

TrickHistory::revertToHistory()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 4
nc 1
nop 2
dl 0
loc 5
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace App\History;
4
5
use Doctrine\ORM\EntityManagerInterface;
6
7
class TrickHistory
8
{
9
10
    /**
11
     * @var EntityManagerInterface
12
     */
13
    private $em;
14
15
    private $repo;
16
17
    public function __construct(EntityManagerInterface $em)
18
    {
19
        $this->em = $em;
20
        $this->repo = $this->em->getRepository('Gedmo\Loggable\Entity\LogEntry');
21
    }
22
23
    public function getHistory($id)
24
    {
25
        $trick = $this->em->find('App\Entity\Trick', $id);
26
        $logs = $this->repo->getLogEntries($trick);
27
28
        return $logs;
29
    }
30
31
    public function revertToHistory($id, $historyId){
32
        $trick = $this->em->find('App\Entity\Trick', $id);
33
        $this->repo->revert($trick, $historyId);
34
        $this->em->persist($trick);
35
        $this->em->flush();
36
    }
37
38
39
40
41
}