1
|
|
|
<?php |
2
|
|
|
/** |
3
|
|
|
* Plugins Management |
4
|
|
|
* @author Joe Huss <[email protected]> |
5
|
|
|
* @copyright 2019 |
6
|
|
|
* @package MyAdmin |
7
|
|
|
* @category Plugins |
8
|
|
|
*/ |
9
|
|
|
|
10
|
|
|
namespace MyAdmin\Plugins\Command; |
11
|
|
|
|
12
|
|
|
use Symfony\Component\Console\Input\InputInterface; |
13
|
|
|
use Symfony\Component\Console\Output\OutputInterface; |
14
|
|
|
use Composer\Command\BaseCommand; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Class UpdatePlugins |
18
|
|
|
* |
19
|
|
|
* @package MyAdmin\Plugins\Command |
20
|
|
|
*/ |
21
|
|
|
class UpdatePlugins extends BaseCommand |
22
|
|
|
{ |
23
|
|
|
protected function configure() |
24
|
|
|
{ |
25
|
|
|
$this |
26
|
|
|
->setName('myadmin:update-plugins') // the name of the command (the part after "bin/console") |
27
|
|
|
->setDescription('Finds and Caches Plugins into MyAdmin') // the short description shown while running "php bin/console list" |
28
|
|
|
->setHelp('This command allows you to create a user...'); // the full command description shown when running the command with the "--help" option |
29
|
|
|
} |
30
|
|
|
|
31
|
|
|
/** (optional) |
32
|
|
|
* This method is executed before the interact() and the execute() methods. |
33
|
|
|
* Its main purpose is to initialize variables used in the rest of the command methods. |
34
|
|
|
* |
35
|
|
|
* @param \Symfony\Component\Console\Input\InputInterface $input |
36
|
|
|
* @param \Symfony\Component\Console\Output\OutputInterface $output |
37
|
|
|
*/ |
38
|
|
|
protected function initialize(InputInterface $input, OutputInterface $output) |
39
|
|
|
{ |
40
|
|
|
} |
41
|
|
|
|
42
|
|
|
/** (optional) |
43
|
|
|
* This method is executed after initialize() and before execute(). |
44
|
|
|
* Its purpose is to check if some of the options/arguments are missing and interactively |
45
|
|
|
* ask the user for those values. This is the last place where you can ask for missing |
46
|
|
|
* options/arguments. After this command, missing options/arguments will result in an error. |
47
|
|
|
* |
48
|
|
|
* @param \Symfony\Component\Console\Input\InputInterface $input |
49
|
|
|
* @param \Symfony\Component\Console\Output\OutputInterface $output |
50
|
|
|
*/ |
51
|
|
|
protected function interact(InputInterface $input, OutputInterface $output) |
52
|
|
|
{ |
53
|
|
|
} |
54
|
|
|
|
55
|
|
|
|
56
|
|
|
/** (required) |
57
|
|
|
* This method is executed after interact() and initialize(). |
58
|
|
|
* It contains the logic you want the command to execute. |
59
|
|
|
* |
60
|
|
|
* @param InputInterface $input |
61
|
|
|
* @param OutputInterface $output |
62
|
|
|
*/ |
63
|
|
|
protected function execute(InputInterface $input, OutputInterface $output) |
64
|
|
|
{ |
65
|
|
|
$output->writeln([ // outputs multiple lines to the console (adding "\n" at the end of each line) |
66
|
|
|
'User Creator', |
67
|
|
|
'============', |
68
|
|
|
'' |
69
|
|
|
]); |
70
|
|
|
$output->write('You are about to '); // outputs a message without adding a "\n" at the end of the line |
71
|
|
|
$output->write('create a user.'); |
72
|
|
|
|
73
|
|
|
/** Coloring |
74
|
|
|
* @link http://symfony.com/doc/current/console/coloring.html |
75
|
|
|
*/ |
76
|
|
|
$output->writeln('<info>foo</info>'); // green text |
77
|
|
|
$output->writeln('<comment>foo</comment>'); // yellow text |
78
|
|
|
$output->writeln('<question>foo</question>'); // black text on a cyan background |
79
|
|
|
$output->writeln('<error>foo</error>'); // white text on a red background |
80
|
|
|
|
81
|
|
|
/** Formatting |
82
|
|
|
* @link http://symfony.com/doc/current/components/console/helpers/formatterhelper.html |
83
|
|
|
*/ |
84
|
|
|
$formatter = $this->getHelper('formatter'); |
85
|
|
|
// Section - [SomeSection] Here is some message related to that section |
86
|
|
|
$formattedLine = $formatter->formatSection('SomeSection', 'Here is some message related to that section'); |
87
|
|
|
$output->writeln($formattedLine); |
88
|
|
|
// Error Block |
89
|
|
|
$errorMessages = ['Error!', 'Something went wrong']; |
90
|
|
|
$formattedBlock = $formatter->formatBlock($errorMessages, 'error'); |
91
|
|
|
$output->writeln($formattedBlock); |
92
|
|
|
// Truncated Messages |
93
|
|
|
$message = 'This is a very long message, which should be truncated'; |
94
|
|
|
$truncatedMessage = $formatter->truncate($message, 7); // This is... |
|
|
|
|
95
|
|
|
$truncatedMessage = $formatter->truncate($message, 7, '!!'); // result: This is!! |
96
|
|
|
$output->writeln($truncatedMessage); |
97
|
|
|
|
98
|
|
|
/** Table |
99
|
|
|
* @link http://symfony.com/doc/current/components/console/helpers/table.html |
100
|
|
|
*/ |
101
|
|
|
|
102
|
|
|
/** Style |
103
|
|
|
* @link http://symfony.com/doc/current/console/style.html |
104
|
|
|
*/ |
105
|
|
|
|
106
|
|
|
/** Process Helper |
107
|
|
|
* @link http://symfony.com/doc/current/components/console/helpers/processhelper.html |
108
|
|
|
*/ |
109
|
|
|
/** Progress Bar |
110
|
|
|
* @link http://symfony.com/doc/current/components/console/helpers/progressbar.html |
111
|
|
|
*/ |
112
|
|
|
/** Question Helper |
113
|
|
|
* @link http://symfony.com/doc/current/components/console/helpers/questionhelper.html |
114
|
|
|
*/ |
115
|
|
|
} |
116
|
|
|
} |
117
|
|
|
|