Completed
Push — develop ( ba756e...8c7c04 )
by Andrea
15:47
created

GenerateFormCommand   A

Complexity

Total Complexity 10

Size/Duplication

Total Lines 221
Duplicated Lines 0 %

Test Coverage

Coverage 95.51%

Importance

Changes 0
Metric Value
eloc 149
dl 0
loc 221
ccs 85
cts 89
cp 0.9551
rs 10
c 0
b 0
f 0
wmc 10

7 Methods

Rating   Name   Duplication   Size   Complexity  
A configure() 0 8 1
A generateFormsDefaultTableValues() 0 17 1
A generateFormRouting() 0 26 2
A execute() 0 47 2
A getRoutingCode() 0 49 1
A copyTableStructureWiew() 0 22 2
A getControllerCode() 0 27 1
1
<?php
2
3
namespace Cdf\PannelloAmministrazioneBundle\Command;
4
5
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
6
use Symfony\Component\Console\Input\InputArgument;
7
use Symfony\Component\Console\Input\InputOption;
8
use Symfony\Component\Console\Input\InputInterface;
9
use Symfony\Component\Console\Output\OutputInterface;
10
use Symfony\Component\Filesystem\Filesystem;
11
use Symfony\Component\Finder\Finder;
12
use Fi\OsBundle\DependencyInjection\OsFunctions;
13
14
class GenerateFormCommand extends ContainerAwareCommand
15
{
16
17
    protected $apppaths;
18
    protected $genhelper;
19
    protected $pammutils;
20
    private $generatemplate;
21
22 3
    protected function configure()
23
    {
24
        $this
25 3
                ->setName('pannelloamministrazione:generateformcrud')
26 3
                ->setDescription('Genera le views per il crud')
27 3
                ->setHelp('Genera le views per il crud, <br/>bi.mwb AppBundle default [--schemaupdate]<br/>')
28 3
                ->addArgument('entityform', InputArgument::REQUIRED, 'Il nome entity del form da creare')
29 3
                ->addOption('generatemplate', InputOption::VALUE_OPTIONAL);
30 3
    }
31
32 1
    protected function execute(InputInterface $input, OutputInterface $output)
33
    {
34 1
        set_time_limit(0);
35 1
        $this->apppaths = $this->getContainer()->get("pannelloamministrazione.projectpath");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal pannelloamministrazione.projectpath 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...
36 1
        $pammutils = $this->getContainer()->get("pannelloamministrazione.utils");
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 6 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...
Coding Style Comprehensibility introduced by
The string literal pannelloamministrazione.utils 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...
37
38 1
        $bundlename = "App";
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 11 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...
Coding Style Comprehensibility introduced by
The string literal App 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...
39 1
        $entityform = $input->getArgument('entityform');
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 11 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 1
        $this->generatemplate = $input->getOption('generatemplate');
41
42 1
        $phpPath = OsFunctions::getPHPExecutableFromPath();
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...
43 1
        $command = $phpPath . ' ' . $this->apppaths->getConsole() . ' --env=dev make:form ';
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...
44 1
        $resultcrud = $pammutils->runCommand($command . $entityform . "Type" . " " . $entityform);
0 ignored issues
show
Bug introduced by
Are you sure $entityform of type null|string|string[] can be used in concatenation? ( Ignorable by Annotation )

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

44
        $resultcrud = $pammutils->runCommand($command . /** @scrutinizer ignore-type */ $entityform . "Type" . " " . $entityform);
Loading history...
Coding Style Comprehensibility introduced by
The string literal Type 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 Comprehensibility introduced by
The string literal 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...
45 1
        if ($resultcrud['errcode'] == 0) {
46 1
            $fs = new Filesystem();
47
            //Controller
48 1
            $controlleFile = $this->apppaths->getSrcPath() . '/Controller/' . $entityform . 'Controller.php';
49
50 1
            $formFile = $this->apppaths->getSrcPath() . '/Form/' . $entityform . 'Type.php';
51
52 1
            $lines = file($formFile, FILE_IGNORE_NEW_LINES);
53
            
54 1
            array_splice($lines, 8, 0, 'use Symfony\Component\Form\Extension\Core\Type\SubmitType;');
0 ignored issues
show
Bug introduced by
It seems like $lines can also be of type false; however, parameter $input of array_splice() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

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

54
            array_splice(/** @scrutinizer ignore-type */ $lines, 8, 0, 'use Symfony\Component\Form\Extension\Core\Type\SubmitType;');
Loading history...
55
            
56 1
            array_splice($lines, 14, 0, "        \$submitparms = array("
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal \$submitparms = array( 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...
57 1
                    . "'label' => 'Salva','attr' => array(\"class\" => \"btn-outline-primary bisubmit\"));");
58
            
59 1
            array_splice($lines, 16, 0, "            ->add('submit', SubmitType::class, \$submitparms)");
60
61 1
            array_splice($lines, count($lines) - 3, 0, "            'parametriform' => array()");
62 1
            file_put_contents($formFile, implode("\n", $lines));
63
64 1
            $code = $this->getControllerCode(str_replace('/', '\\', $bundlename), $entityform);
65 1
            $fs->dumpFile($controlleFile, $code);
66 1
            $output->writeln("<info>Creato " . $controlleFile . "</info>");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal <info>Creato 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 Comprehensibility introduced by
The string literal </info> 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...
67
68
            //Routing
69 1
            $retmsg = $this->generateFormRouting($entityform);
70
            //Twig template
71 1
            $this->copyTableStructureWiew($entityform);
72
73 1
            $this->generateFormsDefaultTableValues($entityform);
74 1
            $output->writeln("<info>" . $retmsg . "</info>");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal <info> 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 Comprehensibility introduced by
The string literal </info> 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...
75 1
            return 0;
76
        } else {
77
            $output->writeln("<error>" . $resultcrud['errmsg'] . "</error>");
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal <error> 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 Comprehensibility introduced by
The string literal </error> 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...
78
            return 1;
79
        }
80
    }
81
82 1
    private function generateFormRouting($entityform)
83
    {
84
        //Routing del form
85 1
        $bundlename = 'App';
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...
86 1
        $fs = new Filesystem();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 10 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...
87 1
        $routingFile = $this->apppaths->getSrcPath() . '/../config/routes/' . strtolower($entityform) . '.yml';
88
89 1
        $code = $this->getRoutingCode(str_replace('/', '', $bundlename), $entityform);
90 1
        $fs->dumpFile($routingFile, $code);
91
92 1
        $dest = $this->apppaths->getSrcPath() . '/../config/routes.yaml';
93
94 1
        $routingContext = str_replace('/', '', $bundlename) . '_' . $entityform . ':' . "\n" .
95 1
                '  resource: routes/' . strtolower($entityform) . '.yml' . "\n" .
96 1
                '  prefix: /' . $entityform . "\n\n";
97
98
        //Si fa l'append nel file routing del bundle per aggiungerci le rotte della tabella che stiamo gestendo
99 1
        $fh = file_get_contents($dest);
100 1
        if ($fh !== false) {
101 1
            file_put_contents($dest, $routingContext . $fh);
102 1
            $retmsg = 'Routing ' . $dest . " generato automaticamente da pannelloammonistrazionebundle\n\n* * * * CLEAR CACHE * * * *\n";
103
        } else {
104
            $retmsg = 'Impossibile generare il ruoting automaticamente da pannelloammonistrazionebundle\n';
105
        }
106
107 1
        return $retmsg;
108
    }
109
110 1
    private function copyTableStructureWiew($entityform)
111
    {
112 1
        $fs = new Filesystem();
113
        /*$publicfolder = $this->apppaths->getPublicPath();
0 ignored issues
show
Unused Code Comprehensibility introduced by
59% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
114
115
        if (!$fs->exists($publicfolder . "/js")) {
116
            $fs->mkdir($publicfolder . "/js", 0777);
117
        }
118
119
        if (!$fs->exists($publicfolder . "/css")) {
120
            $fs->mkdir($publicfolder . "/css", 0777);
121
        }*/
122
123 1
        $templatetablefolder = $this->apppaths->getTemplatePath() . DIRECTORY_SEPARATOR . $entityform;
124 1
        $crudfolder = $this->getContainer()->get('kernel')->locateResource('@BiCoreBundle')
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 10 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...
125 1
                . DIRECTORY_SEPARATOR . 'Resources/views/Standard/Crud';
126 1
        $tabellafolder = $this->getContainer()->get('kernel')->locateResource('@BiCoreBundle')
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 7 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...
127 1
                . DIRECTORY_SEPARATOR . 'Resources/views/Standard/Tabella';
128
129 1
        $fs->mirror($crudfolder, $templatetablefolder . '/Crud');
130 1
        if ($this->generatemplate) {
131
            $fs->mirror($tabellafolder, $templatetablefolder . '/Tabella');
132
        }
133
134
        //$fs->touch($publicfolder . DIRECTORY_SEPARATOR . "js" . DIRECTORY_SEPARATOR . $entityform . ".js");
135
        //$fs->touch($publicfolder . DIRECTORY_SEPARATOR . "css" . DIRECTORY_SEPARATOR . $entityform . ".css");
136 1
    }
137
138 1
    private function generateFormsDefaultTableValues($entityform)
139
    {
140
        //Si inserisce il record di default nella tabella permessi
141 1
        $em = $this->getContainer()->get('doctrine')->getManager();
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 7 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...
142 1
        $ruoloAmm = $em->getRepository('BiCoreBundle:Ruoli')->findOneBy(array('superadmin' => true)); //SuperAdmin
143
144 1
        $newPermesso = new \Cdf\BiCoreBundle\Entity\Permessi();
145 1
        $newPermesso->setCrud('crud');
146 1
        $newPermesso->setModulo($entityform);
147 1
        $newPermesso->setRuoli($ruoloAmm);
148 1
        $em->persist($newPermesso);
149 1
        $em->flush();
150
151 1
        $tabelle = new \Cdf\BiCoreBundle\Entity\Colonnetabelle();
152 1
        $tabelle->setNometabella($entityform);
153 1
        $em->persist($tabelle);
154 1
        $em->flush();
155 1
    }
156
157 1
    private function getControllerCode($bundlename, $tabella)
158
    {
159
        $codeTemplate = <<<EOF
160 1
<?php
161
namespace [bundle]\Controller;
162
163
use Symfony\Component\HttpFoundation\Request;
164
use Symfony\Component\HttpFoundation\Response;
165
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
166
use Cdf\BiCoreBundle\Controller\FiController;
167
use Cdf\BiCoreBundle\Utils\Tabella\ParametriTabella;
168
use [bundle]\Entity\[tabella];
169
use [bundle]\Form\[tabella]Type;
170
                
171
/**
172
* [tabella] controller.
173
*
174
*/
175
176
class [tabella]Controller extends FiController {
177
178
}
179
EOF;
180 1
        $codebundle = str_replace('[bundle]', $bundlename, $codeTemplate);
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...
181 1
        $code = str_replace('[tabella]', $tabella, $codebundle);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 9 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...
182
183 1
        return $code;
184
    }
185
186 1
    private function getRoutingCode($bundlename, $tabella)
187
    {
188
        $codeTemplate = <<<'EOF'
189 1
[tabella]_container:
190
    path:  /
191
    defaults: { _controller: '[bundle]\Controller\[tabella]Controller::index' }
192
193
[tabella]_indexdettaglio:
194
    path:  /indexDettaglio
195
    defaults: { _controller: '[bundle]\Controller\[tabella]Controller::indexDettaglio' }
196
197
[tabella]_new:
198
    path:  /new
199
    defaults: { _controller: '[bundle]\Controller\[tabella]Controller::new' }
200
    requirements: { methods: get|post }
201
202
[tabella]_edit:
203
    path:  /{id}/edit
204
    defaults: { _controller: '[bundle]\Controller\[tabella]Controller::edit' }
205
206
[tabella]_update:
207
    path:  /{id}/update
208
    defaults: { _controller: '[bundle]\Controller\[tabella]Controller::update' }
209
    requirements: { methods: post|put }
210
211
[tabella]_aggiorna:
212
    path:  /aggiorna
213
    defaults: { _controller: '[bundle]\Controller\[tabella]Controller::aggiorna' }
214
    requirements: { methods: post|put }
215
216
[tabella]_delete:
217
    path:  /{id}/delete
218
    defaults: { _controller: '[bundle]\Controller\[tabella]Controller::delete' }
219
    requirements: { methods: post|delete }
220
221
[tabella]_deletemultiple:
222
    path:  /delete
223
    defaults: { _controller: '[bundle]\Controller\[tabella]Controller::delete' }
224
    requirements: { methods: post|delete }
225
226
[tabella]_tabella:
227
    path:  /tabella
228
    defaults: { _controller: '[bundle]\Controller\[tabella]Controller::tabella' }
229
    requirements: { methods: post }
230
EOF;
231 1
        $codebundle = str_replace('[bundle]', $bundlename, $codeTemplate);
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...
232 1
        $code = str_replace('[tabella]', $tabella, $codebundle);
0 ignored issues
show
Coding Style introduced by
Equals sign not aligned with surrounding assignments; expected 9 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...
233
234 1
        return $code;
235
    }
236
}
237