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.
Completed
Push — develop ( 613b22...b02ffb )
by Borut
03:01
created

MyController::settingsAction()   B

Complexity

Conditions 3
Paths 3

Size

Total Lines 46
Code Lines 27

Duplication

Lines 27
Ratio 58.7 %

Importance

Changes 4
Bugs 3 Features 0
Metric Value
c 4
b 3
f 0
dl 27
loc 46
rs 8.9411
cc 3
eloc 27
nc 3
nop 2
1
<?php
2
3
namespace Application\Controller\MembersArea;
4
5
use Silex\Application;
6
use Symfony\Component\HttpFoundation\Request;
7
use Symfony\Component\HttpFoundation\Response;
8
use Application\Form\Type\User\SettingsType;
9
use Application\Form\Type\User\PasswordType;
10
11
/**
12
 * @author Borut Balažek <[email protected]>
13
 */
14
class MyController
15
{
16
    /**
17
     * @param Application $app
18
     *
19
     * @return Response
20
     */
21
    public function indexAction(Application $app)
22
    {
23
        return $app->redirect(
24
            $app['url_generator']->generate('members-area.my.profile')
25
        );
26
    }
27
28
    /**
29
     * @param Application $app
30
     *
31
     * @return Response
32
     */
33
    public function profileAction(Application $app)
34
    {
35
        return new Response(
36
            $app['twig']->render(
37
                'contents/members-area/my/profile.html.twig'
38
            )
39
        );
40
    }
41
42
    /**
43
     * @param Request     $request
44
     * @param Application $app
45
     *
46
     * @return Response
47
     */
48
    public function settingsAction(Request $request, Application $app)
49
    {
50
        $data = array();
51
52
        $form = $app['form.factory']->create(
53
            new SettingsType(),
54
            $app['user']
55
        );
56
57 View Code Duplication
        if ($request->getMethod() == 'POST') {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
58
            $form->handleRequest($request);
59
60
            if ($form->isValid()) {
61
                $userEntity = $form->getData();
62
63
                /*** Image ***/
64
                $userEntity
65
                    ->getProfile()
66
                    ->setImageUploadPath($app['baseUrl'].'/assets/uploads/')
67
                    ->setImageUploadDir(WEB_DIR.'/assets/uploads/')
68
                    ->imageUpload()
69
                ;
70
71
                $app['orm.em']->persist($userEntity);
72
                $app['orm.em']->flush();
73
74
                $app['flashbag']->add(
75
                    'success',
76
                    $app['translator']->trans(
77
                        'Your settings were successfully saved!'
78
                    )
79
                );
80
            } else {
81
                $app['orm.em']->refresh($app['user']);
82
            }
83
        }
84
85
        $data['form'] = $form->createView();
86
87
        return new Response(
88
            $app['twig']->render(
89
                'contents/members-area/my/settings.html.twig',
90
                $data
91
            )
92
        );
93
    }
94
95
    /**
96
     * @param Request     $request
97
     * @param Application $app
98
     *
99
     * @return Response
100
     */
101
    public function passwordAction(Request $request, Application $app)
102
    {
103
        $data = array();
104
105
        $form = $app['form.factory']->create(
106
            new PasswordType(),
107
            $app['user']
108
        );
109
110
        if ($request->getMethod() == 'POST') {
111
            $form->handleRequest($request);
112
113
            if ($form->isValid()) {
114
                $userEntity = $form->getData();
115
116
                if ($userEntity->getPlainPassword()) {
117
                    $userEntity->setPlainPassword(
118
                        $userEntity->getPlainPassword(),
119
                        $app['security.encoder_factory']
120
                    );
121
122
                    $app['orm.em']->persist($userEntity);
123
                    $app['orm.em']->flush();
124
125
                    $app['flashbag']->add(
126
                        'success',
127
                        $app['translator']->trans(
128
                            'Your password was successfully changed!'
129
                        )
130
                    );
131
                }
132
            }
133
        }
134
135
        $data['form'] = $form->createView();
136
137
        return new Response(
138
            $app['twig']->render(
139
                'contents/members-area/my/password.html.twig',
140
                $data
141
            )
142
        );
143
    }
144
}
145