Skip to content

Commit

Permalink
Merge pull request #226 from lenybernard/fix/widget-command-generation
Browse files Browse the repository at this point in the history
Fix/widget command generation
  • Loading branch information
Leny BERNARD committed Oct 5, 2015
2 parents 276cfc6 + 4b3bf18 commit fc300c6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 14 deletions.
18 changes: 9 additions & 9 deletions Bundle/WidgetBundle/Command/CreateWidgetCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public function configure()
new InputOption('namespace', '', InputOption::VALUE_REQUIRED, 'The namespace of the widget bundle to create'),
new InputOption('dir', '', InputOption::VALUE_REQUIRED, 'The directory where to create the bundle'),
new InputOption('bundle-name', '', InputOption::VALUE_REQUIRED, 'The optional bundle name'),
new InputOption('org-name', '', InputOption::VALUE_REQUIRED, 'Your organisation name'),
new InputOption('orgname', '', InputOption::VALUE_REQUIRED, 'Your organisation name'),
new InputOption('widget-name', '', InputOption::VALUE_REQUIRED, 'The widget name'),
new InputOption('format', '', InputOption::VALUE_REQUIRED, 'Use the format for configuration files (php, xml, yml, or annotation)'),
new InputOption('structure', '', InputOption::VALUE_NONE, 'Whether to generate the whole directory structure'),
Expand Down Expand Up @@ -102,10 +102,10 @@ protected function execute(InputInterface $input, OutputInterface $output)
$bundle = strtr($namespace, ['\\' => '']);
}

$orgname = $input->getOption('org-name');
$orgname = $input->getOption('orgname');

if (null === $input->getOption('org-name')) {
$orgname = $input->setOption('org-name', 'friendsofsymfony');
if (null === $input->getOption('orgname')) {
$orgname = $input->setOption('orgname', 'friendsofvictoire');
}

$parent = $input->getOption('parent');
Expand Down Expand Up @@ -252,21 +252,21 @@ protected function interact(InputInterface $input, OutputInterface $output)
$input->setOption('namespace', $namespace);
}

$orgname = $input->getOption('org-name');
$orgname = $input->getOption('orgname');

if (null === $orgname) {
$output->writeln([
'',
'A composer.json file will be generated, we need to knpw under which organisation you will publish the widget',
'A composer.json file will be generated, we need to know under which organisation you will publish the widget',
'',
'The default organisation will be FriendsOfVictoire',
'The default organisation will be friendsofvictoire',
]);
$question = new ConfirmationQuestion($questionHelper->getQuestion('Under which organisation do you want to publish your widget ?', 'friendsofvictoire'), false);
$question = new Question($questionHelper->getQuestion('Under which organisation do you want to publish your widget ?', 'friendsofvictoire'), 'friendsofvictoire');

$orgname = $questionHelper->ask($input, $output, $question);
}

$input->setOption('org-name', $orgname);
$input->setOption('orgname', $orgname);

$parent = $input->getOption('parent');

Expand Down
2 changes: 1 addition & 1 deletion Bundle/WidgetBundle/Generator/WidgetGenerator.php
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public function generate($namespace, $bundle, $dir, $format, $structure, $fields

if ($contentResolver) {
$parameters['parentResolver'] = class_exists('Victoire\\Widget\\'.$parent.'Bundle\\Widget\\Resolver\\Widget'.$parent.'ContentResolver');
$this->renderFile('widget/ContentResolver.php.twig', $dir.'/Widget/Resolver/Widget'.$widget.'ContentResolver.php', $parameters);
$this->renderFile('widget/ContentResolver.php.twig', $dir.'/Resolver/Widget'.$widget.'ContentResolver.php', $parameters);
}
}

Expand Down
6 changes: 4 additions & 2 deletions Bundle/WidgetBundle/Resources/skeleton/README.md.twig
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ Need to add a {{ widget|lower }} in a victoire cms website ?
First you need to have a valid Symfony2 Victoire edition.
Then you just have to run the following composer command :

php composer.phar require victoire/{{ widget|lower }}-widget
```
php composer.phar require {{ orgname }}/{{ widget|lower }}-widget
```

Do not forget to add the bundle in your AppKernel !
Declare your widget in your AppKernel:

```php
class AppKernel extends Kernel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ services:
tags:
- { name: victoire_widget.widget_content_resolver, alias: {{widget}} }

#alias to the entity
#entity alias
victoire.widget.{{ widget|lower }}:
class: {{ namespace }}\Entity\Widget{{ widget }}

#alias to the form
#form alias
victoire.widget.form.{{ widget|lower }}:
class: {{ namespace }}\Form\Widget{{ widget }}Type
tags:
Expand Down

0 comments on commit fc300c6

Please sign in to comment.