PonthubFileController   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 3

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A download() 0 15 2
1
<?php
2
3
namespace KI\PonthubBundle\Controller;
4
5
use KI\CoreBundle\Controller\SubresourceController;
6
use KI\PonthubBundle\Entity\PonthubFileUser;
7
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
8
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
9
10
// Surcouche pour les fichiers de type PonthubFile
11
class PonthubFileController extends SubresourceController
12
{
13
    /**
14
     * Enregistre un téléchargement Ponthub et redirige vers la Ressource
15
     * @param  PonthubFile $item Le fichier à télécharger
16
     * @return mixed             La ressource distante
17
     */
18
    protected function download($item)
19
    {
20
        $this->trust(!$this->is('EXTERIEUR'));
21
22
        if (!$item->hasBeenDownloaded()) {
23
            $download = new PonthubFileUser();
24
            $download->setFile($item);
25
            $download->setUser($this->user);
26
            $download->setDate(time());
27
            $this->manager->persist($download);
28
            $this->manager->flush();
29
        }
30
31
        return $this->redirect($item->fileUrl());
32
    }
33
}
34