Completed
Push — 4.0 ( 9c8a0d...69eff6 )
by Hideki
04:59 queued 10s
created

AbstractRepository   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 56
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 4

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 56
ccs 6
cts 6
cp 1
rs 10
c 0
b 0
f 0
wmc 6
lcom 2
cbo 4

5 Methods

Rating   Name   Duplication   Size   Complexity  
A delete() 0 4 1
A save() 0 4 1
A getCacheLifetime() 0 8 2
A isPostgreSQL() 0 4 1
A isMySQL() 0 4 1
1
<?php
2
3
/*
4
 * This file is part of EC-CUBE
5
 *
6
 * Copyright(c) EC-CUBE CO.,LTD. All Rights Reserved.
7
 *
8
 * http://www.ec-cube.co.jp/
9
 *
10
 * For the full copyright and license information, please view the LICENSE
11
 * file that was distributed with this source code.
12
 */
13
14
namespace Eccube\Repository;
15
16
use Doctrine\DBAL\DBALException;
17
use Eccube\Entity\AbstractEntity;
18
use Doctrine\Bundle\DoctrineBundle\Repository\ServiceEntityRepository;
19
20
abstract class AbstractRepository extends ServiceEntityRepository
21
{
22
    /**
23
     * @var array
24
     */
25
    protected $eccubeConfig;
26
27
    /**
28
     * エンティティを削除します。
29
     *
30
     * @param AbstractEntity $entity
31
     */
32 2
    public function delete($entity)
33
    {
34 2
        $this->getEntityManager()->remove($entity);
35
    }
36
37
    /**
38
     * エンティティの登録/保存します。
39
     *
40
     * @param $entity|AbstractEntity エンティティ
41
     */
42 8
    public function save($entity)
43
    {
44 8
        $this->getEntityManager()->persist($entity);
45
    }
46
47 859
    protected function getCacheLifetime()
48
    {
49
        if ($this->eccubeConfig !== null) {
50
            return $this->eccubeConfig['eccube_result_cache_lifetime'];
51 859
        }
52
53
        return 0;
54
    }
55
56
    /**
57
     * PostgreSQL環境かどうかを判定します。
58
     * @return bool
59
     * @throws DBALException
60
     */
61
    protected function isPostgreSQL()
62
    {
63
        return 'postgresql' == $this->getEntityManager()->getConnection()->getDatabasePlatform()->getName();
64
    }
65
66
    /**
67
     * MySQL環境かどうかを判定します。
68
     * @return bool
69
     * @throws DBALException
70
     */
71
    protected function isMySQL()
72
    {
73
        return 'mysql' == $this->getEntityManager()->getConnection()->getDatabasePlatform()->getName();
74
    }
75
}
76