GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

EmailController   A
last analyzed

Complexity

Total Complexity 8

Size/Duplication

Total Lines 93
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Importance

Changes 0
Metric Value
wmc 8
lcom 0
cbo 5
dl 0
loc 93
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A indexAction() 0 15 2
B previewTemplatesAction() 0 63 6
1
<?php
2
3
namespace Application\Controller\MembersArea\Tools;
4
5
use Application\Tool\Helpers;
6
use Silex\Application;
7
use Symfony\Component\HttpFoundation\Request;
8
use Symfony\Component\HttpFoundation\Response;
9
10
/**
11
 * @author Borut Balažek <[email protected]>
12
 */
13
class EmailController
14
{
15
    /**
16
     * @param Application $app
17
     *
18
     * @return Response
19
     */
20
    public function indexAction(Application $app)
21
    {
22
        $data = array();
23
24
        if (!$app['security']->isGranted('ROLE_ADMIN')) {
25
            $app->abort(403);
26
        }
27
28
        return new Response(
29
            $app['twig']->render(
30
                'contents/members-area/tools/email.html.twig',
31
                $data
32
            )
33
        );
34
    }
35
36
    /**
37
     * @param Request     $request
38
     * @param Application $app
39
     *
40
     * @return Response
41
     */
42
    public function previewTemplatesAction(Request $request, Application $app)
43
    {
44
        if (!$app['security']->isGranted('ROLE_ADMIN')) {
45
            $app->abort(403);
46
        }
47
48
        $data = array();
49
50
        $templates = array();
51
        $template = $request->query->get('template', false);
52
        $raw = $request->query->has('raw');
53
54
        // Set some possible global defaults for the template
55
        $emailData = array(
56
            'app' => $app,
57
            'user' => $app['user'],
58
            'content' => 'Hello world!',
59
            'formData' => array(
60
                'message' => 'Just a test message!',
61
            ),
62
            'e' => new \Exception('Some error happened!'),
63
        );
64
65
        if ($template && $raw) {
66
            $app['debug'] = false;
67
            $app['showProfiler'] = false;
68
69
            return $app['mailer.css_to_inline_styles_converter'](
70
                'emails/'.$template.'.html.twig',
71
                $emailData
72
            );
73
        }
74
75
        $templatesArray = Helpers::rglob(
76
            APP_DIR.'/templates/emails/*.html.twig'
77
        );
78
79
        if (!empty($templatesArray)) {
80
            foreach ($templatesArray as $templatePath) {
81
                $templatePath = str_replace(
82
                    APP_DIR.'/templates/emails/',
83
                    '',
84
                    $templatePath
85
                );
86
87
                $templates[] = str_replace(
88
                    '.html.twig',
89
                    '',
90
                    $templatePath
91
                );
92
            }
93
        }
94
95
        $data['template'] = $template;
96
        $data['templates'] = $templates;
97
98
        return new Response(
99
            $app['twig']->render(
100
                'contents/members-area/tools/email/preview-templates.html.twig',
101
                $data
102
            )
103
        );
104
    }
105
}
106