Completed
Pull Request — experimental/3.1 (#2515)
by Kentaro
40:30
created

LoadEventSubscriber::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
cc 1
eloc 2
nc 1
nop 1
dl 0
loc 4
ccs 0
cts 2
cp 0
crap 2
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace Eccube\Doctrine\EventSubscriber;
4
5
use Doctrine\Common\EventSubscriber;
6
use Doctrine\Common\Persistence\Event\LifecycleEventArgs;
7
use Doctrine\ORM\Events;
8
use Eccube\Application;
9
use Eccube\Entity\AbstractEntity;
10
11
class LoadEventSubscriber implements EventSubscriber
0 ignored issues
show
introduced by
Missing class doc comment
Loading history...
12
{
13
    /**
14
     * @var Application
15
     */
16
    private $app;
17
18
    /**
19
     * @param Application $app
20
     */
21
    public function __construct(Application $app)
22
    {
23
        $this->app = $app;
24
    }
25
26
    public function getSubscribedEvents()
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
27
    {
28
        return [Events::postLoad];
29
    }
30
31
    public function postLoad(LifecycleEventArgs $args)
0 ignored issues
show
introduced by
Missing function doc comment
Loading history...
32
    {
33
        $entity = $args->getObject();
34
        if ($entity instanceof AbstractEntity) {
35
            $entity->setAnnotationReader($this->app['eccube.di.annotation_reader']);
36
        }
37
    }
38
}
39