Skip to content

Commit d50e647

Browse files
committed
Merge branch 'development'
2 parents a519610 + 1f23abe commit d50e647

File tree

108 files changed

+562
-372
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

108 files changed

+562
-372
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
11
language: php
22

33
php:
4+
- 7.1
45
- 7.0
56
- 5.6
6-
- 5.5
77

88
before_script:
9-
- composer global require "phpunit/phpunit=4.*"
9+
- composer global require "phpunit/phpunit"
1010
- composer install
1111

1212
script: ~/.composer/vendor/bin/phpunit

DEVELOPMENT.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,7 @@ To make _dcg_ avaible in any system location append this line to your _.bashrc_
2525
Then after you have logged out and in the _dcg_ will be accessible through _$dcg_ global shell variable.
2626

2727
## Testing
28-
We stick to PHPUnit 4 because PHP 5.5 is not supported by PHPUnit 5. You can
29-
install it as follows:
28+
Install PHPUnit globally:
3029
```shell
3130
composer global require "phpunit/phpunit=4.*"
3231
```

composer.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,10 @@
33
"description": "Drupal code generator",
44
"require": {
55
"php": ">=5.5.9",
6-
"symfony/console": "~3.0",
7-
"symfony/filesystem": "~3.0",
8-
"twig/twig": "~1.0",
9-
"symfony/yaml": "~3.0"
6+
"symfony/console": "~3.1",
7+
"symfony/filesystem": "~3.1",
8+
"twig/twig": "~1.24",
9+
"symfony/yaml": "~3.1"
1010
},
1111
"autoload": {
1212
"files": ["src/bootstrap.php"],

src/Commands/BaseGenerator.php

Lines changed: 17 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,21 +55,21 @@ abstract class BaseGenerator extends Command implements GeneratorInterface {
5555
/**
5656
* The file system utility.
5757
*
58-
* @var Filesystem
58+
* @var \Symfony\Component\Filesystem\Filesystem
5959
*/
6060
protected $filesystem;
6161

6262
/**
6363
* The twig environment.
6464
*
65-
* @var Twig_Environment
65+
* @var \Twig_Environment
6666
*/
6767
protected $twig;
6868

6969
/**
7070
* The yaml dumper.
7171
*
72-
* @var Dumper
72+
* @var \Symfony\Component\Yaml\Dumper
7373
*/
7474
protected $yamlDumper;
7575

@@ -96,6 +96,13 @@ abstract class BaseGenerator extends Command implements GeneratorInterface {
9696

9797
/**
9898
* Constructs a generator command.
99+
*
100+
* @param \Symfony\Component\Filesystem\Filesystem $filesystem
101+
* The file system utility.
102+
* @param \Twig_Environment $twig
103+
* The twig environment.
104+
* @param \Symfony\Component\Yaml\Dumper $yaml_dumper
105+
* The yaml dumper.
99106
*/
100107
public function __construct(Filesystem $filesystem, Twig_Environment $twig, Dumper $yaml_dumper) {
101108
parent::__construct();
@@ -142,15 +149,15 @@ protected function configure() {
142149
}
143150

144151
/**
145-
* Renders file.
152+
* Renders a template.
146153
*
147154
* @param string $template
148155
* Twig template.
149156
* @param array $vars
150157
* Template variables.
151158
*
152159
* @return string
153-
* The rendered file.
160+
* A strign representing the rendered output.
154161
*/
155162
protected function render($template, array $vars) {
156163
return $this->twig->render($template, $vars);
@@ -159,9 +166,9 @@ protected function render($template, array $vars) {
159166
/**
160167
* Asks the user for template variables.
161168
*
162-
* @param InputInterface $input
169+
* @param \Symfony\Component\Console\Input\InputInterface $input
163170
* Input instance.
164-
* @param OutputInterface $output
171+
* @param \Symfony\Component\Console\Output\OutputInterface $output
165172
* Output instance.
166173
* @param array $questions
167174
* List of questions that the user should answer.
@@ -306,17 +313,17 @@ protected function execute(InputInterface $input, OutputInterface $output) {
306313
/**
307314
* Asks a question to the user.
308315
*
309-
* @param InputInterface $input
316+
* @param \Symfony\Component\Console\Input\InputInterface $input
310317
* Input instance.
311-
* @param OutputInterface $output
318+
* @param \Symfony\Component\Console\Output\OutputInterface $output
312319
* Output instance.
313320
* @param string $question_text
314321
* The text of the question.
315322
* @param string $default_value
316323
* Default value for the question.
317324
*
318325
* @return string
319-
* The user anwser.
326+
* The user answer.
320327
*/
321328
protected function ask(InputInterface $input, OutputInterface $output, $question_text, $default_value) {
322329
/** @var \Symfony\Component\Console\Helper\QuestionHelper $helper */

src/Commands/Drupal_7/CToolsPlugin/Access.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ class Access extends BasePlugin {
1010
protected $name = 'd7:ctools-plugin:access';
1111
protected $description = 'Generates CTools access plugin';
1212
protected $template = 'd7/ctools-access-plugin.twig';
13+
protected $directory = 'plugins/access';
1314

1415
}

src/Commands/Drupal_7/CToolsPlugin/BasePlugin.php

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,15 +13,19 @@
1313
abstract class BasePlugin extends BaseGenerator {
1414

1515
protected $template;
16+
protected $directory;
1617

1718
/**
1819
* {@inheritdoc}
1920
*/
2021
protected function interact(InputInterface $input, OutputInterface $output) {
2122

2223
$questions = [
23-
'name' => ['Plugin name', [$this, 'defaultName']],
24-
'machine_name' => ['Plugin machine name', [$this, 'defaultMachineName']],
24+
'machine_name' => ['Module machine name', [$this, 'defaultMachineName']],
25+
'plugin_name' => ['Plugin name', [$this, 'defaultName']],
26+
'plugin_machine_name' => [
27+
'Plugin machine name', [$this, 'defaultPluginMachineName'],
28+
],
2529
'description' => ['Plugin description', 'TODO: Write description for the plugin'],
2630
'package' => ['Package', 'custom'],
2731
];
@@ -37,8 +41,15 @@ protected function interact(InputInterface $input, OutputInterface $output) {
3741
->getHelper('question')
3842
->ask($input, $output, $question);
3943

40-
$this->files[$vars['machine_name'] . '.inc'] = $this->render($this->template, $vars);
44+
$this->files[$this->directory . '/' . $vars['plugin_machine_name'] . '.inc'] = $this->render($this->template, $vars);
4145

4246
}
4347

48+
/**
49+
* Returns default value for the plugin machine name question.
50+
*/
51+
protected function defaultPluginMachineName($vars) {
52+
return self::human2machine($vars['plugin_name']);
53+
}
54+
4455
}

src/Commands/Drupal_7/CToolsPlugin/ContentType.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ class ContentType extends BasePlugin {
1010
protected $name = 'd7:ctools-plugin:content-type';
1111
protected $description = 'Generates CTools content type plugin';
1212
protected $template = 'd7/ctools-content-type-plugin.twig';
13+
protected $directory = 'plugins/content_types';
1314

1415
}

src/Commands/Drupal_7/CToolsPlugin/Relationship.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,6 @@ class Relationship extends BasePlugin {
1010
protected $name = 'd7:ctools-plugin:relationship';
1111
protected $description = 'Generates CTools relationship plugin';
1212
protected $template = 'd7/ctools-relationship-plugin.twig';
13+
protected $directory = 'plugins/relationships';
1314

1415
}

src/Commands/Drupal_7/ViewsPlugin/ArgumentDefault.php

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ protected function interact(InputInterface $input, OutputInterface $output) {
2323
'name' => ['Module name', [$this, 'defaultName']],
2424
'machine_name' => ['Module machine name', [$this, 'defaultMachineName']],
2525
'plugin_name' => ['Plugin name', 'Example'],
26-
'plugin_machine_name' => ['Plugin machine name', [$this, 'defaultPluginMachineName']],
26+
'plugin_machine_name' => [
27+
'Plugin machine name', [$this, 'defaultPluginMachineName'],
28+
],
2729
];
2830

2931
$vars = $this->collectVars($input, $output, $questions);

src/Commands/Drupal_8/BreadcrumbBuilder.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ protected function interact(InputInterface $input, OutputInterface $output) {
3636
[
3737
'name' => 'breadcrumb_builder',
3838
'priority' => 1000,
39-
]
39+
],
4040
],
4141
];
4242

0 commit comments

Comments
 (0)