namespace Drupal\Console\Command\Generate;
-use Symfony\Component\Console\Command\Command;
+use Drupal\Console\Core\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Drupal\Console\Command\Shared\ConfirmationTrait;
use Drupal\Console\Command\Shared\ModuleTrait;
use Drupal\Console\Command\Shared\ServicesTrait;
-use Drupal\Console\Core\Command\Shared\CommandTrait;
use Drupal\Console\Generator\EntityBundleGenerator;
-use Drupal\Console\Core\Style\DrupalStyle;
use Drupal\Console\Extension\Manager;
use Drupal\Console\Utils\Validator;
class EntityBundleCommand extends Command
{
- use CommandTrait;
use ModuleTrait;
use ServicesTrait;
use ConfirmationTrait;
->setName('generate:entity:bundle')
->setDescription($this->trans('commands.generate.entity.bundle.description'))
->setHelp($this->trans('commands.generate.entity.bundle.help'))
- ->addOption('module', null, InputOption::VALUE_REQUIRED, $this->trans('commands.common.options.module'))
+ ->addOption(
+ 'module',
+ null,
+ InputOption::VALUE_REQUIRED,
+ $this->trans('commands.common.options.module')
+ )
->addOption(
'bundle-name',
null,
null,
InputOption::VALUE_OPTIONAL,
$this->trans('commands.generate.entity.bundle.options.bundle-title')
- );
+ )
+ ->setAliases(['geb']);
}
/**
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
- $io = new DrupalStyle($input, $output);
-
- // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmGeneration
- if (!$this->confirmGeneration($io)) {
+ // @see use Drupal\Console\Command\Shared\ConfirmationTrait::confirmOperation
+ if (!$this->confirmOperation()) {
return 1;
}
$bundleName = $input->getOption('bundle-name');
$bundleTitle = $input->getOption('bundle-title');
- $generator = $this->generator;
//TODO:
// $generator->setLearning($learning);
- $generator->generate($module, $bundleName, $bundleTitle);
+ $this->generator->generate([
+ 'module' => $module,
+ 'bundle_name' => $bundleName,
+ 'bundle_title' => $bundleTitle,
+ ]);
return 0;
}
*/
protected function interact(InputInterface $input, OutputInterface $output)
{
- $io = new DrupalStyle($input, $output);
-
// --module option
- $module = $input->getOption('module');
- if (!$module) {
- // @see Drupal\Console\Command\Shared\ModuleTrait::moduleQuestion
- $module = $this->moduleQuestion($io);
- $input->setOption('module', $module);
- }
+ $this->getModuleOption();
// --bundle-name option
$bundleName = $input->getOption('bundle-name');
if (!$bundleName) {
- $bundleName = $io->ask(
+ $bundleName = $this->getIo()->ask(
$this->trans('commands.generate.entity.bundle.questions.bundle-name'),
'default',
function ($bundleName) {
// --bundle-title option
$bundleTitle = $input->getOption('bundle-title');
if (!$bundleTitle) {
- $bundleTitle = $io->ask(
+ $bundleTitle = $this->getIo()->ask(
$this->trans('commands.generate.entity.bundle.questions.bundle-title'),
'default',
function ($bundle_title) {