Completed
Push — master ( 82664b...176635 )
by Julito
88:10 queued 58:03
created

ProfileController   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 3

Importance

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

3 Methods

Rating   Name   Duplication   Size   Complexity  
B fileAction() 0 27 2
A getSoundAction() 0 6 1
A getTemplatePath() 0 4 1
1
<?php
2
/* For licensing terms, see /license.txt */
3
4
namespace Chamilo\CoreBundle\Controller\User;
5
6
use Chamilo\CoreBundle\Controller\BaseController;
7
use Silex\Application;
8
use Symfony\Component\Routing\Annotation\Route;
9
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Method;
10
use Symfony\Component\HttpFoundation\Response;
11
12
/**
13
 * Class ProfileController
14
 * @package Chamilo\CoreBundle\Controller
15
 */
16
class ProfileController extends BaseController
17
{
18
    /**
19
     * My files
20
     * @Route("/{username}/files")
21
     * @Method({"GET"})
22
     */
23
    public function fileAction($username)
24
    {
25
        if ($this->getUser()->getUsername() != $username) {
26
            return $this->abort(401);
27
        }
28
29
        $userId = \UserManager::get_user_id_from_username($username);
30
        $userInfo = api_get_user_info($userId);
31
32
        $this->getTemplate()->assign(
33
            'driver_list',
34
            'PersonalDriver,DropBoxDriver'
35
        );
36
37
        $editor = $this->getTemplate()->renderTemplate(
0 ignored issues
show
Bug introduced by
The method renderTemplate() does not exist on Symfony\Bundle\TwigBundle\TwigEngine. Did you maybe mean render()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
38
            $this->getHtmlEditor()->getEditorStandAloneTemplate()
39
        );
40
41
        $this->getTemplate()->assign('user', $userInfo);
42
        $this->getTemplate()->assign('editor', $editor);
43
44
        $response = $this->getTemplate()->renderTemplate(
0 ignored issues
show
Bug introduced by
The method renderTemplate() does not exist on Symfony\Bundle\TwigBundle\TwigEngine. Did you maybe mean render()?

This check marks calls to methods that do not seem to exist on an object.

This is most likely the result of a method being renamed without all references to it being renamed likewise.

Loading history...
45
            $this->getTemplatePath().'files.tpl'
46
        );
47
48
        return new Response($response, 200, array());
49
    }
50
51
    /**
52
     * Gets that rm.wav sound
53
     * @Route("/{username}/sounds/{file}")
54
     * @Method({"GET"})
55
     */
56
    public function getSoundAction()
57
    {
58
        $file = api_get_path(LIBRARY_PATH).'elfinder/rm.wav';
59
60
        return $this->app->sendFile($file);
61
    }
62
63
    /**
64
     * {@inheritdoc}
65
     */
66
    public function getTemplatePath()
67
    {
68
        return 'user/';
69
    }
70
}
71