Completed
Pull Request — master (#33)
by Pavel
03:21
created

AdminInfoUsersController::showAccountAction()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 21
Code Lines 12

Duplication

Lines 6
Ratio 28.57 %

Code Coverage

Tests 8
CRAP Score 3.1825

Importance

Changes 2
Bugs 0 Features 2
Metric Value
c 2
b 0
f 2
dl 6
loc 21
ccs 8
cts 11
cp 0.7272
rs 9.3142
cc 3
eloc 12
nc 4
nop 2
crap 3.1825
1
<?php
2
3
namespace AppBundle\Controller\Admin;
4
5
use AppBundle\Entity\ModuleUser;
6
use AppBundle\Entity\User;
7
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
8
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
9
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Template;
10
use Symfony\Component\HttpFoundation\Request;
11
use Symfony\Component\HttpFoundation\Response;
12
13
class AdminInfoUsersController extends Controller
14
{
15
    /**
16
     * @Route("/admin/account/{id}", name="admin_account")
17
     * @Template("@App/admin/AdminInfoUsers/showAccount.html.twig")
18
     */
19 1
    public function showAccountAction(Request $request, User $id = null)
20
    {
21 1
        $em = $this->getDoctrine()->getManager();
22
23 1
        $request->get('module') ? $module = $request->get('module') : $module = null;
24
25 1 View Code Duplication
        if ($module) {
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...
26
            $moduleAjax = $em->getRepository('AppBundle:PassModule')
27
                ->findAjax($module);
28
29
            return new Response(json_encode(['moduleAjax' => $moduleAjax]));
30
        }
31
32 1
        $modules = $em->getRepository('AppBundle:ModuleUser')
33 1
            ->findModules($id);
34
35
        return [
36 1
            'user' => $id,
37
            'modules' => $modules
38 1
        ];
39
    }
40
}
41