use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
-use Symfony\Component\Console\Command\Command;
+use Drupal\Console\Core\Command\Command;
use Drupal\Console\Command\Shared\ModuleTrait;
-use Drupal\Console\Core\Command\Shared\CommandTrait;
-use Drupal\Console\Core\Style\DrupalStyle;
abstract class EntityCommand extends Command
{
- use CommandTrait;
use ModuleTrait;
private $entityType;
private $commandName;
*/
protected function interact(InputInterface $input, OutputInterface $output)
{
- $io = new DrupalStyle($input, $output);
-
$commandKey = str_replace(':', '.', $this->commandName);
$utils = $this->stringConverter;
// --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();
// --entity-class option
$entityClass = $input->getOption('entity-class');
if (!$entityClass) {
- $entityClass = $io->ask(
+ $entityClass = $this->getIo()->ask(
$this->trans('commands.'.$commandKey.'.questions.entity-class'),
'DefaultEntity',
function ($entityClass) {
// --entity-name option
$entityName = $input->getOption('entity-name');
if (!$entityName) {
- $entityName = $io->ask(
+ $entityName = $this->getIo()->ask(
$this->trans('commands.'.$commandKey.'.questions.entity-name'),
$utils->camelCaseToMachineName($entityClass),
function ($entityName) {
// --label option
$label = $input->getOption('label');
if (!$label) {
- $label = $io->ask(
+ $label = $this->getIo()->ask(
$this->trans('commands.'.$commandKey.'.questions.label'),
$utils->camelCaseToHuman($entityClass)
);
if (!$base_path) {
$base_path = $this->getDefaultBasePath();
}
- $base_path = $io->ask(
+ $base_path = $this->getIo()->ask(
$this->trans('commands.'.$commandKey.'.questions.base-path'),
$base_path
);