MetadataFactory::load()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 17
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 10
nc 2
nop 2
1
<?php
2
3
namespace As3\Bundle\ModlrBundle\DependencyInjection\ServiceLoader;
4
5
use As3\Bundle\ModlrBundle\DependencyInjection\Utility;
6
use Symfony\Component\DependencyInjection\ContainerBuilder;
7
use Symfony\Component\DependencyInjection\Definition;
8
use Symfony\Component\DependencyInjection\Reference;
9
10
/**
11
 * Loads the metadata factory service.
12
 *
13
 * @author  Jacob Bare <[email protected]>
14
 */
15
class MetadataFactory implements ServiceLoaderInterface
16
{
17
    /**
18
     * {@inheritdoc}
19
     */
20
    public function load(array $config, ContainerBuilder $container)
21
    {
22
        $definition = new Definition(
23
            Utility::getLibraryClass('Metadata\MetadataFactory'),
24
            [
25
                new Reference(Utility::getAliasedName('metadata.default_driver')),
26
                new Reference(Utility::getAliasedName('util.entity')),
27
                new Reference(Utility::getAliasedName('event_dispatcher')),
28
            ]
29
        );
30
31
        if (true === $config['metadata']['cache']['enabled']) {
32
            $definition->addMethodCall('setCache', [new Reference(Utility::getAliasedName('metadata.cache'))]);
33
        }
34
        $container->setDefinition(Utility::getAliasedName('metadata.factory'), $definition);
35
        return $this;
36
    }
37
}
38