use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
-use Symfony\Component\Console\Command\Command;
-use Drupal\Console\Core\Command\Shared\CommandTrait;
+use Drupal\Console\Core\Command\Command;
+use Drupal\Console\Utils\Validator;
use Drupal\Console\Command\Shared\ModuleTrait;
use Drupal\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Config\CachedStorage;
-use Drupal\Console\Core\Style\DrupalStyle;
use Drupal\Console\Command\Shared\ExportTrait;
use Drupal\Console\Extension\Manager;
class ExportViewCommand extends Command
{
- use CommandTrait;
use ModuleTrait;
use ExportTrait;
*/
protected $extensionManager;
+ /**
+ * @var Validator
+ */
+ protected $validator;
+
/**
* ExportViewCommand constructor.
*
public function __construct(
EntityTypeManagerInterface $entityTypeManager,
CachedStorage $configStorage,
- Manager $extensionManager
+ Manager $extensionManager,
+ Validator $validator
) {
$this->entityTypeManager = $entityTypeManager;
$this->configStorage = $configStorage;
$this->extensionManager = $extensionManager;
+ $this->validator = $validator;
parent::__construct();
}
null,
InputOption::VALUE_OPTIONAL,
$this->trans('commands.config.export.view.options.include-module-dependencies')
- );
+ )
+ ->setAliases(['cev']);
}
/**
*/
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();
// view-id argument
$viewId = $input->getArgument('view-id');
$viewList[$view->get('id')] = $view->get('label');
}
- $viewId = $io->choiceNoList(
+ $viewId = $this->getIo()->choiceNoList(
$this->trans('commands.config.export.view.questions.view'),
$viewList
);
$optionalConfig = $input->getOption('optional-config');
if (!$optionalConfig) {
- $optionalConfig = $io->confirm(
+ $optionalConfig = $this->getIo()->confirm(
$this->trans('commands.config.export.view.questions.optional-config'),
true
);
$includeModuleDependencies = $input->getOption('include-module-dependencies');
if (!$includeModuleDependencies) {
- $includeModuleDependencies = $io->confirm(
+ $includeModuleDependencies = $this->getIo()->confirm(
$this->trans('commands.config.export.view.questions.include-module-dependencies'),
true
);
protected function execute(InputInterface $input, OutputInterface $output)
{
- $io = new DrupalStyle($input, $output);
-
$module = $input->getOption('module');
$viewId = $input->getArgument('view-id');
$optionalConfig = $input->getOption('optional-config');
// Include module dependencies in export files if export is not optional
if ($includeModuleDependencies) {
if ($dependencies = $this->fetchDependencies($viewNameConfig, 'module')) {
- $this->exportModuleDependencies($io, $module, $dependencies);
+ $this->exportModuleDependencies($module, $dependencies);
}
}
- $this->exportConfigToModule($module, $io, $this->trans('commands.views.export.messages.view_exported'));
+ $this->exportConfigToModule($module, $this->trans('commands.views.export.messages.view-exported'));
}
}