Completed
Push — master ( 625a74...74c3c7 )
by Eric
07:53
created

LocaleResource::__construct()   A

Complexity

Conditions 3
Paths 1

Size

Total Lines 22
Code Lines 18

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 19
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 22
ccs 19
cts 19
cp 1
rs 9.2
cc 3
eloc 18
nc 1
nop 2
crap 3
1
<?php
2
3
/*
4
 * This file is part of the Lug package.
5
 *
6
 * (c) Eric GELOEN <[email protected]>
7
 *
8
 * For the full copyright and license information, please read the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Lug\Component\Locale\Resource;
13
14
use Lug\Bundle\ResourceBundle\Controller\Controller;
15
use Lug\Bundle\ResourceBundle\Repository\Doctrine\MongoDB\Repository as DoctrineMongoDBRepository;
16
use Lug\Bundle\ResourceBundle\Repository\Doctrine\ORM\Repository as DoctrineORMRepository;
17
use Lug\Component\Locale\Form\Type\Doctrine\MongoDB\LocaleChoiceType as DoctrineMongoDBLocaleChoiceType;
18
use Lug\Component\Locale\Form\Type\Doctrine\ORM\LocaleChoiceType as DoctrineORMLocaleChoiceType;
19
use Lug\Component\Locale\Form\Type\LocaleType;
20
use Lug\Component\Locale\Model\Locale;
21
use Lug\Component\Locale\Model\LocaleInterface;
22
use Lug\Component\Resource\Domain\DomainManager;
23
use Lug\Component\Resource\Factory\Factory;
24
use Lug\Component\Resource\Model\Resource;
25
26
/**
27
 * @author GeLo <[email protected]>
28
 */
29
class LocaleResource extends Resource
30
{
31
    /**
32
     * @param string $bundlePath
33
     * @param string $driver
34
     */
35 11
    public function __construct($bundlePath, $driver = self::DRIVER_DOCTRINE_ORM)
36
    {
37 11
        $orm = $driver === self::DRIVER_DOCTRINE_ORM;
38
39 11
        parent::__construct(
40 11
            'locale',
41 11
            $driver,
42 11
            'default',
43 11
            $bundlePath.'/Resources/config/resources',
44 11
            self::DRIVER_MAPPING_FORMAT_XML,
45 11
            LocaleInterface::class,
46 11
            Locale::class,
47 11
            Controller::class,
48 11
            Factory::class,
49 11
            $orm ? DoctrineORMRepository::class : DoctrineMongoDBRepository::class,
50 11
            DomainManager::class,
51 11
            LocaleType::class,
52 11
            $orm ? DoctrineORMLocaleChoiceType::class : DoctrineMongoDBLocaleChoiceType::class,
53 11
            'code',
54
            'code'
55 11
        );
56 11
    }
57
}
58