TranslationHistoryManager::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 6
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 2
crap 1
1
<?php
2
3
/*
4
 * This file is part of the AsmTranslationLoaderBundle package.
5
 *
6
 * (c) Marc Aschmann <[email protected]>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Asm\TranslationLoaderBundle\Doctrine;
13
14
use Asm\TranslationLoaderBundle\Model\TranslationHistoryInterface;
15
use Asm\TranslationLoaderBundle\Model\TranslationHistoryManager as BaseTranslationHistoryManager;
16
use Doctrine\Common\Persistence\ObjectManager;
17
18
/**
19
 * TranslationHistoryManager implementation supporting Doctrine.
20
 *
21
 * @author Christian Flothmann <[email protected]>
22
 */
23
class TranslationHistoryManager extends BaseTranslationHistoryManager
24
{
25
    /**
26
     * @var ObjectManager
27
     */
28
    private $objectManager;
29
30
    /**
31
     * @param ObjectManager $objectManager Object manager for translation history entities
32
     * @param string        $class         Translation history model class name
33
     */
34 3
    public function __construct(ObjectManager $objectManager, $class)
35
    {
36 3
        parent::__construct($class);
37
38 3
        $this->objectManager = $objectManager;
39 3
    }
40
41
    /**
42
     * {@inheritDoc}
43
     */
44 2
    public function updateTranslationHistory(TranslationHistoryInterface $translationHistory, $clear = false)
45
    {
46 2
        $this->objectManager->persist($translationHistory);
47 2
        $this->objectManager->flush();
48
49 2
        if ($clear) {
50 1
            $this->objectManager->clear();
51 1
        }
52 2
    }
53
}
54