Subscriber   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
eloc 7
dl 0
loc 48
ccs 9
cts 9
cp 1
rs 10
c 0
b 0
f 0
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getSubscribedEvents() 0 4 1
A __construct() 0 3 1
A getManager() 0 3 1
A loadClassMetaData() 0 3 1
1
<?php
2
/**
3
 * @copyright Zicht Online <http://zicht.nl>
4
 */
5
6
namespace Zicht\Bundle\PageBundle\Manager\Doctrine;
7
8
use Doctrine\Common\EventSubscriber;
9
use Doctrine\ORM\Event\LoadClassMetadataEventArgs;
10
use Doctrine\ORM\Events;
11
use Symfony\Component\DependencyInjection\ContainerInterface;
12
13
/**
14
 * Subscriber for loading the class metadata for content items and pages. Delegates to
15
 * PageManager::decorateClassMetaData()
16
 */
17
class Subscriber implements EventSubscriber
18
{
19
    /**
20
     * @var ContainerInterface
21
     */
22
    private $container;
23
24
    /**
25
     * Construct the subscriber.
26
     *
27
     * @param \Symfony\Component\DependencyInjection\ContainerInterface $container
28
     */
29 1
    public function __construct(ContainerInterface $container)
30
    {
31 1
        $this->container = $container;
32 1
    }
33
34
35
    /**
36
     * Returns the page manager service.
37
     *
38
     * @return \Zicht\Bundle\PageBundle\Manager\PageManager
39
     */
40 1
    public function getManager()
41
    {
42 1
        return $this->container->get('zicht_page.page_manager');
43
    }
44
45
46
    /**
47
     * Delegates to PageManager::decorateClassMetaData to load the class meta data
48
     *
49
     * @param \Doctrine\ORM\Event\LoadClassMetadataEventArgs $args
50
     * @return void
51
     */
52 1
    public function loadClassMetaData(LoadClassMetadataEventArgs $args)
53
    {
54 1
        $this->getManager()->decorateClassMetaData($args->getClassMetadata());
55 1
    }
56
57
58
    /**
59
     * @{inheritDoc}
60
     */
61 1
    public function getSubscribedEvents()
62
    {
63
        return array(
64
            Events::loadClassMetadata
65 1
        );
66
    }
67
}
68