|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/** |
|
4
|
|
|
* This file is part of slick/mvc package |
|
5
|
|
|
* |
|
6
|
|
|
* For the full copyright and license information, please view the LICENSE |
|
7
|
|
|
* file that was distributed with this source code. |
|
8
|
|
|
*/ |
|
9
|
|
|
|
|
10
|
|
|
namespace Slick\Mvc\Console\Command; |
|
11
|
|
|
|
|
12
|
|
|
use Symfony\Component\Console\Command\Command; |
|
13
|
|
|
use Symfony\Component\Console\Input\InputArgument; |
|
14
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
|
15
|
|
|
use Symfony\Component\Console\Input\InputOption; |
|
16
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
|
17
|
|
|
|
|
18
|
|
|
/** |
|
19
|
|
|
* Generate:controller command |
|
20
|
|
|
* |
|
21
|
|
|
* @package Slick\Mvc\Console\Command |
|
22
|
|
|
* @author Filipe Silva <[email protected]> |
|
23
|
|
|
*/ |
|
24
|
|
|
class GenerateController extends Command |
|
25
|
|
|
{ |
|
26
|
|
|
/** |
|
27
|
|
|
* Configures the current command. |
|
28
|
|
|
*/ |
|
29
|
|
|
protected function configure() |
|
30
|
|
|
{ |
|
31
|
|
|
$this |
|
32
|
|
|
->setName("generate:controller") |
|
33
|
|
|
->setDescription("Generate a controller file for the provided model name.") |
|
34
|
|
|
->addArgument( |
|
35
|
|
|
'modelName', |
|
36
|
|
|
InputArgument::REQUIRED, |
|
37
|
|
|
'Full qualified model class name' |
|
38
|
|
|
) |
|
39
|
|
|
->addOption( |
|
40
|
|
|
'path', |
|
41
|
|
|
'p', |
|
42
|
|
|
InputOption::VALUE_OPTIONAL, |
|
43
|
|
|
'Sets the application path where controllers are located', |
|
44
|
|
|
getcwd().'/src' |
|
45
|
|
|
) |
|
46
|
|
|
->addOption( |
|
47
|
|
|
'out', |
|
48
|
|
|
'o', |
|
49
|
|
|
InputOption::VALUE_OPTIONAL, |
|
50
|
|
|
'The controllers folder where to save the controller.', |
|
51
|
|
|
'Controller' |
|
52
|
|
|
) |
|
53
|
|
|
->addOption( |
|
54
|
|
|
'scaffold', |
|
55
|
|
|
'S', |
|
56
|
|
|
InputOption::VALUE_NONE, |
|
57
|
|
|
'If set the controller will have only the scaffold property set.' |
|
58
|
|
|
) |
|
59
|
|
|
; |
|
60
|
|
|
} |
|
61
|
|
|
|
|
62
|
|
|
/** |
|
63
|
|
|
* Executes the current command. |
|
64
|
|
|
* |
|
65
|
|
|
* This method is not abstract because you can use this class |
|
66
|
|
|
* as a concrete class. In this case, instead of defining the |
|
67
|
|
|
* execute() method, you set the code to execute by passing |
|
68
|
|
|
* a Closure to the setCode() method. |
|
69
|
|
|
* |
|
70
|
|
|
* @param InputInterface $input An InputInterface instance |
|
71
|
|
|
* @param OutputInterface $output An OutputInterface instance |
|
72
|
|
|
* |
|
73
|
|
|
* @return null|integer null or 0 if everything went fine, or an error code |
|
74
|
|
|
* |
|
75
|
|
|
* @throws \LogicException When this abstract method is not implemented |
|
76
|
|
|
* @see setCode() |
|
77
|
|
|
*/ |
|
78
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
|
79
|
|
|
{} |
|
80
|
|
|
} |