Skip to content

Commit a519ee2

Browse files
committed
Merge pull request #23 from VSEphpbb/fixes
Some fixes and updates
2 parents 03d77ee + 746255a commit a519ee2

4 files changed

Lines changed: 58 additions & 57 deletions

File tree

config/skeletons.yml

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ services:
1010
class: phpbb\skeleton\skeleton
1111
arguments:
1212
- 'phplistener'
13-
- true
13+
- false
1414
- []
1515
- ['config/services.yml', 'event/main_listener.php']
1616
tags:
@@ -20,7 +20,7 @@ services:
2020
class: phpbb\skeleton\skeleton
2121
arguments:
2222
- 'htmllistener'
23-
- true
23+
- false
2424
- []
2525
- ['styles/prosilver/template/event/overall_header_navigation_prepend.html']
2626
tags:
@@ -30,7 +30,7 @@ services:
3030
class: phpbb\skeleton\skeleton
3131
arguments:
3232
- 'acp'
33-
- true
33+
- false
3434
- []
3535
- ['acp/main_info.php', 'acp/main_module.php', 'adm/style/acp_demo_body.html', 'language/en/info_acp_demo.php']
3636
tags:
@@ -40,7 +40,7 @@ services:
4040
class: phpbb\skeleton\skeleton
4141
arguments:
4242
- 'migration'
43-
- true
43+
- false
4444
- []
4545
- ['migrations/install_module.php', 'migrations/install_user_schema.php']
4646
tags:
@@ -50,7 +50,7 @@ services:
5050
class: phpbb\skeleton\skeleton
5151
arguments:
5252
- 'service'
53-
- true
53+
- false
5454
- []
5555
- ['service.php', 'config/services.yml', 'config/parameters.yml']
5656
tags:
@@ -60,7 +60,7 @@ services:
6060
class: phpbb\skeleton\skeleton
6161
arguments:
6262
- 'controller'
63-
- true
63+
- false
6464
- []
6565
- ['config/routing.yml', 'config/services.yml', 'event/main_listener.php', 'language/en/common.php', 'controller/main.php', 'styles/prosilver/template/demo_body.html']
6666
tags:
@@ -70,7 +70,7 @@ services:
7070
class: phpbb\skeleton\skeleton
7171
arguments:
7272
- 'ext'
73-
- true
73+
- false
7474
- []
7575
- ['ext.php']
7676
tags:
@@ -80,7 +80,7 @@ services:
8080
class: phpbb\skeleton\skeleton
8181
arguments:
8282
- 'tests'
83-
- true
83+
- false
8484
- []
8585
- ['tests/controller/main_test.php', 'tests/dbal/fixtures/config.xml', 'tests/dbal/simple_test.php', 'tests/functional/demo_test.php', 'phpunit.xml.dist']
8686
tags:
@@ -90,7 +90,7 @@ services:
9090
class: phpbb\skeleton\skeleton
9191
arguments:
9292
- 'travis'
93-
- true
93+
- false
9494
- ['tests']
9595
- ['travis/prepare-phpbb.sh', '.travis.yml']
9696
tags:

console/create.php

Lines changed: 44 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -17,20 +17,32 @@
1717
use phpbb\skeleton\helper\packager;
1818
use phpbb\skeleton\helper\validator;
1919
use phpbb\user;
20-
use Symfony\Component\Console\Helper\DialogHelper;
20+
use Symfony\Component\Console\Helper\QuestionHelper;
2121
use Symfony\Component\Console\Input\InputInterface;
2222
use Symfony\Component\Console\Output\OutputInterface;
23+
use Symfony\Component\Console\Question\ConfirmationQuestion;
24+
use Symfony\Component\Console\Question\Question;
2325

2426
class create extends command
2527
{
28+
/** @var array user input data array */
2629
protected $data = array();
2730

28-
/** @var validator */
29-
protected $validator;
31+
/** @var QuestionHelper $helper */
32+
protected $helper;
33+
34+
/** @var InputInterface */
35+
protected $input;
36+
37+
/** @var OutputInterface */
38+
protected $output;
3039

3140
/** @var packager */
3241
protected $packager;
3342

43+
/** @var validator */
44+
protected $validator;
45+
3446
/**
3547
* Constructor
3648
*
@@ -84,56 +96,52 @@ protected function execute(InputInterface $input, OutputInterface $output)
8496
*/
8597
protected function interact(InputInterface $input, OutputInterface $output)
8698
{
87-
/** @var DialogHelper $dialog */
88-
$dialog = $this->getHelper('dialog');
99+
$this->input = $input;
100+
$this->output = $output;
101+
102+
$this->helper = $this->getHelper('question');
89103

90104
$output->writeln($this->user->lang('SKELETON_CLI_COMPOSER_QUESTIONS'));
91-
$this->get_composer_data($dialog, $output);
105+
$this->get_composer_data();
92106

93107
$output->writeln($this->user->lang('SKELETON_CLI_COMPONENT_QUESTIONS'));
94-
$this->get_component_data($dialog, $output);
108+
$this->get_component_data();
95109
}
96110

97111
/**
98-
* @param DialogHelper $dialog
99-
* @param OutputInterface $output
112+
* Get composer data from the user
100113
*/
101-
protected function get_composer_data(DialogHelper $dialog, OutputInterface $output)
114+
protected function get_composer_data()
102115
{
103116
$dialog_questions = $this->packager->get_composer_dialog_values();
104117
foreach ($dialog_questions['extension'] as $value => $default)
105118
{
106-
$this->data['extension'][$value] = $this->get_user_input($dialog, $output, $value, $default);
119+
$this->data['extension'][$value] = $this->get_user_input($value, $default);
107120
}
108121

109-
$num_authors = $dialog->askAndValidate(
110-
$output,
111-
$this->user->lang('SKELETON_QUESTION_NUM_AUTHORS') . $this->user->lang('COLON'),
112-
array($this->validator, 'validate_num_authors'),
113-
false,
114-
1
115-
);
122+
$question = new Question($this->user->lang('SKELETON_QUESTION_NUM_AUTHORS') . $this->user->lang('COLON'), 1);
123+
$question->setValidator(array($this->validator, 'validate_num_authors'));
124+
$num_authors = $this->helper->ask($this->input, $this->output, $question);
116125

117126
$this->data['authors'] = array();
118127
for ($i = 0; $i < $num_authors; $i++)
119128
{
120129
foreach ($dialog_questions['author'] as $value => $default)
121130
{
122-
$this->data['authors'][$i][$value] = $this->get_user_input($dialog, $output, $value, $default);
131+
$this->data['authors'][$i][$value] = $this->get_user_input($value, $default);
123132
}
124133
}
125134

126135
foreach ($dialog_questions['requirements'] as $value => $default)
127136
{
128-
$this->data['requirements'][$value] = $this->get_user_input($dialog, $output, $value, $default);
137+
$this->data['requirements'][$value] = $this->get_user_input($value, $default);
129138
}
130139
}
131140

132141
/**
133-
* @param DialogHelper $dialog
134-
* @param OutputInterface $output
142+
* Get component data from the user
135143
*/
136-
protected function get_component_data(DialogHelper $dialog, OutputInterface $output)
144+
protected function get_component_data()
137145
{
138146
$components = $this->packager->get_component_dialog_values();
139147
foreach ($components as $component => $details)
@@ -147,44 +155,36 @@ protected function get_component_data(DialogHelper $dialog, OutputInterface $out
147155
}
148156
}
149157

150-
$this->data['components'][$component] = $this->get_user_input($dialog, $output, 'component_' . $component, $details['default']);
158+
$this->data['components'][$component] = $this->get_user_input('component_' . $component, $details['default']);
151159
}
152160
}
153161

154162
/**
155-
* @param DialogHelper $dialog
156-
* @param OutputInterface $output
163+
* Helper for getting user input
164+
*
157165
* @param string $value
158166
* @param mixed $default
159167
* @return mixed|string
160168
*/
161-
protected function get_user_input(DialogHelper $dialog, OutputInterface $output, $value, $default)
169+
protected function get_user_input($value, $default)
162170
{
171+
$dialog = $this->user->lang('SKELETON_QUESTION_' . strtoupper($value)) . $this->user->lang('COLON');
172+
163173
if (method_exists($this->validator, 'validate_' . $value))
164174
{
165-
$return_value = $dialog->askAndValidate(
166-
$output,
167-
$this->user->lang('SKELETON_QUESTION_' . strtoupper($value)) . $this->user->lang('COLON'),
168-
array($this->validator, 'validate_' . $value),
169-
false,
170-
$default
171-
);
175+
$question = new Question($dialog, $default);
176+
$question->setValidator(array($this->validator, 'validate_' . $value));
177+
$return_value = $this->helper->ask($this->input, $this->output, $question);
172178
}
173179
else if (is_bool($default))
174180
{
175-
$return_value = $dialog->askConfirmation(
176-
$output,
177-
$this->user->lang('SKELETON_QUESTION_' . strtoupper($value)) . $this->user->lang('COLON'),
178-
$default
179-
);
181+
$question = new ConfirmationQuestion($dialog, $default);
182+
$return_value = $this->helper->ask($this->input, $this->output, $question);
180183
}
181184
else
182185
{
183-
$return_value = $dialog->ask(
184-
$output,
185-
$this->user->lang('SKELETON_QUESTION_' . strtoupper($value)) . $this->user->lang('COLON'),
186-
$default
187-
);
186+
$question = new Question($dialog, $default);
187+
$return_value = $this->helper->ask($this->input, $this->output, $question);
188188
}
189189

190190
return $return_value;

controller/main.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,8 @@ public function handle()
157157
$this->data['components'][$component] = $this->get_user_input('component_' . $component, $details['default']);
158158
}
159159

160+
$this->template->assign_var('S_POST_ACTION', $this->helper->route('phpbb_skeleton_controller'));
161+
160162
return $this->helper->render('skeleton_body.html', $this->user->lang('PHPBB_SKELETON_EXT'));
161163
}
162164

@@ -194,7 +196,6 @@ protected function get_component_data()
194196
$components = $this->packager->get_component_dialog_values();
195197
foreach ($components as $component => $details)
196198
{
197-
$details['default'] = false;
198199
foreach ($details['dependencies'] as $depends)
199200
{
200201
if (empty($this->data['components'][$depends]))

language/en/common.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,8 @@
2626
'PHPBB_SKELETON_EXT' => 'Create skeleton extension',
2727

2828
'EXTENSION_CLI_SKELETON_SUCCESS' => "<info>Extension created successfully.\nCopy the extension from `store/tmp-ext/` into the `ext/` folder.</info>",
29-
'SKELETON_CLI_COMPOSER_QUESTIONS' => '<comment>Enter the composer.json details (hit enter to leave an option empty)</comment>',
30-
'SKELETON_CLI_COMPONENT_QUESTIONS' => '<comment>Choose the components you’d like installed. Default: y; [y/n]</comment>',
29+
'SKELETON_CLI_COMPOSER_QUESTIONS' => '<comment>Enter composer.json details (hit enter to leave an option empty)</comment>',
30+
'SKELETON_CLI_COMPONENT_QUESTIONS' => '<comment>Install optional components. Default: No; [y/n]</comment>',
3131

3232
'SKELETON_ADD_AUTHOR' => 'Add author',
3333
'SKELETON_QUESTION_VENDOR_NAME' => 'Please enter the vendor name',
@@ -83,7 +83,7 @@
8383
'SKELETON_QUESTION_COMPONENT_SERVICE' => 'Create a sample service?',
8484
'SKELETON_QUESTION_COMPONENT_SERVICE_UI' => 'Service',
8585
'SKELETON_QUESTION_COMPONENT_CONTROLLER' => 'Create a sample controller?',
86-
'SKELETON_QUESTION_COMPONENT_CONTROLLER_UI' => 'Controller (frontpage)',
86+
'SKELETON_QUESTION_COMPONENT_CONTROLLER_UI' => 'Controller (front page)',
8787
'SKELETON_QUESTION_COMPONENT_EXT' => 'Create a sample ext.php?',
8888
'SKELETON_QUESTION_COMPONENT_EXT_UI' => 'Extension base (ext.php)',
8989
'SKELETON_QUESTION_COMPONENT_TESTS' => 'Create sample PHPUnit tests?',

0 commit comments

Comments
 (0)