MediaListener   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 2
dl 0
loc 19
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A onPostSubmit() 0 9 2
1
<?php
2
3
namespace Alpixel\Bundle\MediaBundle\EventListener;
4
5
use Doctrine\ORM\EntityManager;
6
7
class MediaListener
8
{
9
    protected $entityManager;
10
11
    public function __construct(EntityManager $entityManager)
12
    {
13
        $this->entityManager = $entityManager;
14
    }
15
16
    public function onPostSubmit(MediaEvent $event)
17
    {
18
        $media = $event->getMedia();
19
20
        if ($media !== null) {
21
            $media->setLifetime(null);
22
            $this->entityManager->persist($media);
23
        }
24
    }
25
}
26