Passed
Push — master ( f6f1d0...ed56e2 )
by Andrea
69:42 queued 61:17
created

FiCrudController::indexAction()   B

Complexity

Conditions 2
Paths 2

Size

Total Lines 46
Code Lines 31

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 30
CRAP Score 2.0001

Importance

Changes 0
Metric Value
dl 0
loc 46
ccs 30
cts 31
cp 0.9677
rs 8.9411
c 0
b 0
f 0
cc 2
eloc 31
nc 2
nop 1
crap 2.0001
1
<?php
2
3
namespace Fi\CoreBundle\Controller;
4
5
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
6
use Symfony\Component\HttpFoundation\Request;
7
use Symfony\Component\HttpFoundation\Response;
8
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
9
10
class FiCrudController extends Controller
11
{
12
13
    public static $namespace;
14
    public static $bundle;
15
    public static $controller;
16
    public static $action;
17
    public static $parametrigriglia;
18
    public static $canRead;
19
    public static $canDelete;
20
    public static $canCreate;
21
    public static $canUpdate;
22
23 15
    protected function setup(Request $request)
24
    {
25 15
        $matches = array();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
26 15
        $controllo = new \ReflectionClass(get_class($this));
27
28 15
        preg_match('/(.*)\\\(.*)Bundle\\\Controller\\\(.*)Controller/', $controllo->name, $matches);
29
30 15
        self::$namespace = $matches[1];
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
31 15
        self::$bundle = $matches[2];
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
32 15
        self::$controller = $matches[3];
33 15
        self::$action = substr($request->attributes->get('_controller'), strrpos($request->attributes->get('_controller'), ':') + 1);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
34
35 15
        $gestionepermessi = $this->get('ficorebundle.gestionepermessi');
36 15
        self::$canRead = ($gestionepermessi->leggere(array('modulo' => self::$controller)) ? 1 : 0);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
37 15
        self::$canDelete = ($gestionepermessi->cancellare(array('modulo' => self::$controller)) ? 1 : 0);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
38 15
        self::$canCreate = ($gestionepermessi->creare(array('modulo' => self::$controller)) ? 1 : 0);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
39 15
        self::$canUpdate = ($gestionepermessi->aggiornare(array('modulo' => self::$controller)) ? 1 : 0);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
40
        
41 15
        if (!self::$canRead) {
42 1
            throw new AccessDeniedException("Non si hanno i permessi per visualizzare questo contenuto");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal Non si hanno i permessi ...izzare questo contenuto does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
43
        }
44 14
    }
45
46
    /**
47
     * Lists all tables entities.
48
     */
49 4
    public function indexAction(Request $request)
50
    {
51
        /* @var $em \Doctrine\ORM\EntityManager */
52 4
        $this->setup($request);
53 4
        $namespace = $this->getNamespace();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
54 4
        $bundle = $this->getBundle();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
55 4
        $controller = $this->getController();
56
57 4
        if (!self::$canRead) {
58
            throw new AccessDeniedException("Non si hanno i permessi per visualizzare questo contenuto");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal Non si hanno i permessi ...izzare questo contenuto does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
59
        }
60
61 4
        $container = $this->container;
62
63 4
        $idpassato = $request->get('id');
64
65 4
        $nomebundle = $namespace . $bundle . 'Bundle';
66
67 4
        $repotabelle = $this->get('OpzioniTabella_repository');
68
69 4
        $paricevuti = array('nomebundle' => $nomebundle, 'nometabella' => $controller, 'container' => $container);
70
71 4
        $testatagriglia = Griglia::testataPerGriglia($paricevuti);
72
73 4
        $testatagriglia['multisearch'] = 1;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 19 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
74 4
        $testatagriglia['showconfig'] = 1;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 20 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
75 4
        $testatagriglia['overlayopen'] = 1;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 19 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
76 4
        $testatagriglia['showadd'] = self::$canCreate;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 23 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
77 4
        $testatagriglia['showedit'] = self::$canUpdate;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 22 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
78 4
        $testatagriglia['showdel'] = self::$canDelete;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 23 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
79 4
        $testatagriglia["filterToolbar_searchOnEnter"] = true;
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal filterToolbar_searchOnEnter does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
80 4
        $testatagriglia["filterToolbar_searchOperators"] = true;
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal filterToolbar_searchOperators does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
81
82 4
        $testatagriglia['parametritesta'] = json_encode($paricevuti);
83
84 4
        $this->setParametriGriglia(array('request' => $request));
0 ignored issues
show
introduced by
The method setParametriGriglia() does not exist on Fi\CoreBundle\Controller\FiCrudController. Maybe you want to declare this class abstract? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

84
        $this->/** @scrutinizer ignore-call */ 
85
               setParametriGriglia(array('request' => $request));
Loading history...
85 4
        $testatagriglia['parametrigriglia'] = json_encode(self::$parametrigriglia);
86
87 4
        $testata = $repotabelle->editTestataFormTabelle($testatagriglia, $controller, $container);
88 4
        return $this->render(
89 4
            $nomebundle . ':' . $controller . ':index.html.twig',
90
            array(
91 4
                    'nomecontroller' => $controller,
92 4
                    'testata' => $testata,
93 4
                    'canread' => self::$canRead,
94 4
                    'idpassato' => $idpassato,
95
                        )
96
        );
97
    }
98
99
    /**
100
     * Creates a new table entity.
101
     */
102 2
    public function createAction(Request $request)
103
    {
104 2
        $this->setup($request);
105 2
        $namespace = $this->getNamespace();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
106 2
        $bundle = $this->getBundle();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
107 2
        $controller = $this->getController();
108
109 2
        if (!self::$canCreate) {
110
            throw new AccessDeniedException("Non si hanno i permessi per creare questo contenuto");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal Non si hanno i permessi ...creare questo contenuto does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
111
        }
112
113 2
        $nomebundle = $namespace . $bundle . 'Bundle';
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
114 2
        $classbundle = $namespace . '\\' . $bundle . 'Bundle' . '\\Entity\\' . $controller;
115 2
        $formbundle = $namespace . '\\' . $bundle . 'Bundle' . '\\Form\\' . $controller;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
116
117 2
        $entity = new $classbundle();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
118 2
        $formType = $formbundle . 'Type';
119
120 2
        $form = $this->createForm(
121 2
            $formType,
122 2
            $entity,
123
            array('attr' => array(
124 2
                'id' => 'formdati' . $controller,
125
                ),
126 2
                'action' => $this->generateUrl($controller . '_create'),
127
                )
128
        );
129
130 2
        $form->submit($request->request->get($form->getName()));
131
132 2
        if ($form->isValid()) {
133 2
            $em = $this->getDoctrine()->getManager();
134 2
            $em->persist($entity);
135 2
            $em->flush();
136
137 2
            $continua = $request->get('continua');
138 2
            if ($continua == 0) {
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing $continua of type null|mixed to 0; this is ambiguous as not only 0 == 0 is true, but null == 0 is true, too. Consider using a strict comparison ===.
Loading history...
139 2
                return new Response('OK');
140
            } else {
141
                return $this->redirect($this->generateUrl($controller . '_edit', array('id' => $entity->getId())));
142
            }
143
        }
144
145
        return $this->render(
146
            $nomebundle . ':' . $controller . ':new.html.twig',
147
            array(
148
                    'nomecontroller' => $controller,
149
                    'entity' => $entity,
150
                    'form' => $form->createView(),
151
                        )
152
        );
153
    }
154
155
    /**
156
     * Displays a form to create a new table entity.
157
     */
158 2
    public function newAction(Request $request)
159
    {
160 2
        $this->setup($request);
161 2
        $namespace = $this->getNamespace();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
162 2
        $bundle = $this->getBundle();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
163 2
        $controller = $this->getController();
164
165 2
        if (!self::$canCreate) {
166
            throw new AccessDeniedException("Non si hanno i permessi per creare questo contenuto");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal Non si hanno i permessi ...creare questo contenuto does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
167
        }
168
169 2
        $nomebundle = $namespace . $bundle . 'Bundle';
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
170 2
        $classbundle = $namespace . '\\' . $bundle . 'Bundle' . '\\Entity\\' . $controller;
171 2
        $formbundle = $namespace . '\\' . $bundle . 'Bundle' . '\\Form\\' . $controller;
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
172 2
        $formType = $formbundle . 'Type';
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 4 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
173
174 2
        $entity = new $classbundle();
175
176 2
        $form = $this->createForm(
177 2
            $formType,
178 2
            $entity,
179
            array('attr' => array(
180 2
                'id' => 'formdati' . $controller,
181
                ),
182 2
                'action' => $this->generateUrl($controller . '_create'),
183
                )
184
        );
185
186 2
        return $this->render(
187 2
            $nomebundle . ':' . $controller . ':new.html.twig',
188
            array(
189 2
                    'nomecontroller' => $controller,
190 2
                    'entity' => $entity,
191 2
                    'form' => $form->createView(),
192
                        )
193
        );
194
    }
195
196
    /**
197
     * Displays a form to edit an existing table entity.
198
     */
199 2
    public function editAction(Request $request, $id)
200
    {
201
        /* @var $em \Doctrine\ORM\EntityManager */
202 2
        $this->setup($request);
203 2
        $namespace = $this->getNamespace();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
204 2
        $bundle = $this->getBundle();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
205 2
        $controller = $this->getController();
206
207 2
        if (!self::$canUpdate) {
208
            throw new AccessDeniedException("Non si hanno i permessi per modificare questo contenuto");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal Non si hanno i permessi ...ficare questo contenuto does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
209
        }
210
211 2
        $nomebundle = $namespace . $bundle . 'Bundle';
212 2
        $formbundle = $namespace . '\\' . $bundle . 'Bundle' . '\\Form\\' . $controller;
213 2
        $formType = $formbundle . 'Type';
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
214
215 2
        $elencomodifiche = $this->elencoModifiche($controller, $id);
0 ignored issues
show
introduced by
The method elencoModifiche() does not exist on Fi\CoreBundle\Controller\FiCrudController. Maybe you want to declare this class abstract? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

215
        /** @scrutinizer ignore-call */ 
216
        $elencomodifiche = $this->elencoModifiche($controller, $id);
Loading history...
216
217 2
        $em = $this->getDoctrine()->getManager();
218
219 2
        $entity = $em->getRepository($nomebundle . ':' . $controller)->find($id);
220
221 2
        if (!$entity) {
222
            throw $this->createNotFoundException('Unable to find ' . $controller . ' entity.');
223
        }
224
225 2
        $editForm = $this->createForm(
226 2
            $formType,
227 2
            $entity,
228
            array('attr' => array(
229 2
                'id' => 'formdati' . $controller,
230
                ),
231 2
                'action' => $this->generateUrl($controller . '_update', array('id' => $entity->getId())),
232
                )
233
        );
234
235 2
        $deleteForm = $this->createDeleteForm($id);
236
237 2
        return $this->render(
238 2
            $nomebundle . ':' . $controller . ':edit.html.twig',
239
            array(
240 2
                    'entity' => $entity,
241 2
                    'nomecontroller' => $controller,
242 2
                    'edit_form' => $editForm->createView(),
243 2
                    'delete_form' => $deleteForm->createView(),
244 2
                    'elencomodifiche' => $elencomodifiche,
245
                        )
246
        );
247
    }
248
249
    /**
250
     * Edits an existing table entity.
251
     */
252 2
    public function updateAction(Request $request, $id)
253
    {
254
        /* @var $em \Doctrine\ORM\EntityManager */
255 2
        $this->setup($request);
256 2
        $namespace = $this->getNamespace();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
257 2
        $bundle = $this->getBundle();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
258 2
        $controller = $this->getController();
259
260 2
        if (!self::$canUpdate) {
261
            throw new AccessDeniedException("Non si hanno i permessi per aggiornare questo contenuto");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal Non si hanno i permessi ...ornare questo contenuto does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
262
        }
263
264 2
        $nomebundle = $namespace . $bundle . 'Bundle';
265 2
        $formbundle = $namespace . '\\' . $bundle . 'Bundle' . '\\Form\\' . $controller;
266 2
        $formType = $formbundle . 'Type';
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 3 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
267
268 2
        $repoStorico = $this->container->get('Storicomodifiche_repository');
269
270 2
        $em = $this->getDoctrine()->getManager();
271
272 2
        $entity = $em->getRepository($nomebundle . ':' . $controller)->find($id);
273
274 2
        if (!$entity) {
275
            throw $this->createNotFoundException('Unable to find ' . $controller . ' entity.');
276
        }
277
278 2
        $deleteForm = $this->createDeleteForm($id);
279
280 2
        $editForm = $this->createForm(
281 2
            $formType,
282 2
            $entity,
283
            array('attr' => array(
284 2
                'id' => 'formdati' . $controller,
285
                ),
286 2
                'action' => $this->generateUrl($controller . '_update', array('id' => $entity->getId())),
287
                )
288
        );
289
290 2
        $editForm->submit($request->request->get($editForm->getName()));
291
292 2
        if ($editForm->isValid()) {
293 2
            $originalData = $em->getUnitOfWork()->getOriginalEntityData($entity);
294
295 2
            $em->persist($entity);
296 2
            $em->flush();
297
298 2
            $newData = $em->getUnitOfWork()->getOriginalEntityData($entity);
299 2
            $changes = $repoStorico->isRecordChanged($nomebundle, $controller, $originalData, $newData);
300
301 2
            if ($changes) {
302 1
                $repoStorico->saveHistory($controller, $changes, $id, $this->getUser());
303
            }
304
305 2
            $continua = $request->get('continua');
306 2
            if ($continua == 0) {
0 ignored issues
show
Bug Best Practice introduced by
It seems like you are loosely comparing $continua of type null|mixed to 0; this is ambiguous as not only 0 == 0 is true, but null == 0 is true, too. Consider using a strict comparison ===.
Loading history...
307 2
                return new Response('OK');
308
            } else {
309
                return $this->redirect($this->generateUrl($controller . '_edit', array('id' => $id)));
310
            }
311
        }
312
313
        return $this->render(
314
            $nomebundle . ':' . $controller . ':edit.html.twig',
315
            array(
316
                    'entity' => $entity,
317
                    'edit_form' => $editForm->createView(),
318
                    'delete_form' => $deleteForm->createView(),
319
                    'nomecontroller' => $controller,
320
                        )
321
        );
322
    }
323
324
    /**
325
     * Edits an existing table entity.
326
     */
327
    public function aggiornaAction(Request $request)
328
    {
329
        /* @var $em \Doctrine\ORM\EntityManager */
330
        $this->setup($request);
331
        $namespace = $this->getNamespace();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
332
        $bundle = $this->getBundle();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
333
        $controller = $this->getController();
334
335
        if (!self::$canUpdate) {
336
            throw new AccessDeniedException("Non si hanno i permessi per aggiornare questo contenuto");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal Non si hanno i permessi ...ornare questo contenuto does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
337
        }
338
339
        $nomebundle = $namespace . $bundle . 'Bundle';
340
341
        $id = $this->get('request')->request->get('id');
342
343
        $em = $this->getDoctrine()->getManager();
344
345
        $entity = $em->getRepository($nomebundle . ':' . $controller)->find($id);
346
347
        if (!$entity) {
348
            throw $this->createNotFoundException('Unable to find ' . $controller . ' entity.');
349
        }
350
351
        throw $this->createNotFoundException("Implementare a seconda dell'esigenza 'aggiornaAction' del controller "
352
                . $nomebundle
353
                . '/'
354
                . $controller);
355
    }
356
357
    /**
358
     * Deletes a table entity.
359
     */
360 2
    public function deleteAction(Request $request)
361
    {
362
        /* @var $em \Doctrine\ORM\EntityManager */
363 2
        $this->setup($request);
364 2
        $namespace = $this->getNamespace();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
365 2
        $bundle = $this->getBundle();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 5 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
366 2
        $controller = $this->getController();
367
368 2
        $nomebundle = $namespace . $bundle . 'Bundle';
369
370
        try {
371 2
            $em = $this->getDoctrine()->getManager();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
372 2
            $qb = $em->createQueryBuilder();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 2 spaces but found 1 space

This check looks for multiple assignments in successive lines of code. It will report an issue if the operators are not in a straight line.

To visualize

$a = "a";
$ab = "ab";
$abc = "abc";

will produce issues in the first and second line, while this second example

$a   = "a";
$ab  = "ab";
$abc = "abc";

will produce no issues.

Loading history...
373 2
            $ids = explode(',', $request->get('id'));
374 2
            $qb->delete($nomebundle . ':' . $controller, 'u')
375 2
                    ->andWhere('u.id IN (:ids)')
376 2
                    ->setParameter('ids', $ids);
377
378 2
            $query = $qb->getQuery();
379 2
            $query->execute();
380
        } catch (\Exception $e) {
381
            $response = new Response();
382
            $response->setStatusCode('200');
383
384
            return new Response('404');
385
        }
386
387 2
        return new Response('OK');
388
    }
389
390
    /**
391
     * Creates a form to delete a table entity by id.
392
     *
393
     * @param mixed $id The entity id
394
     *
395
     * @return \Symfony\Component\Form\Form The form
396
     */
397
    protected function createDeleteForm($id)
398
    {
399
        return $this->createFormBuilder(array('id' => $id))
400
                        ->add('id', get_class(new \Symfony\Component\Form\Extension\Core\Type\HiddenType()))
401
                        ->getForm();
402
    }
403
404 14
    protected function getNamespace()
405
    {
406 14
        return self::$namespace;
407
    }
408
409 14
    protected function getBundle()
410
    {
411 14
        return self::$bundle;
412
    }
413
414 14
    protected function getController()
415
    {
416 14
        return self::$controller;
417
    }
418
419
    protected function getAction()
420
    {
421
        return self::$action;
422
    }
423
}
424