Completed
Push — master ( aa6181...9c1eab )
by Joshua
8s
created

MetadataFactory::load()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 16
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 16
rs 9.4285
cc 2
eloc 9
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
            ]
28
        );
29
30
        if (true === $config['metadata']['cache']['enabled']) {
31
            $definition->addMethodCall('setCache', [new Reference(Utility::getAliasedName('metadata.cache'))]);
32
        }
33
        $container->setDefinition(Utility::getAliasedName('metadata.factory'), $definition);
34
        return $this;
35
    }
36
}
37