use Drupal\Console\Generator\UpdateGenerator;
use Drupal\Console\Command\Shared\ModuleTrait;
use Drupal\Console\Command\Shared\ConfirmationTrait;
-use Symfony\Component\Console\Command\Command;
-use Drupal\Console\Core\Command\Shared\CommandTrait;
-use Drupal\Console\Core\Style\DrupalStyle;
+use Drupal\Console\Core\Command\Command;
use Drupal\Console\Extension\Manager;
use Drupal\Console\Core\Utils\ChainQueue;
use Drupal\Console\Utils\Site;
+use Drupal\Console\Utils\Validator;
/**
* Class UpdateCommand
{
use ModuleTrait;
use ConfirmationTrait;
- use CommandTrait;
/**
- * @var Manager
-*/
+ * @var Manager
+ */
protected $extensionManager;
/**
- * @var UpdateGenerator
-*/
+ * @var UpdateGenerator
+ */
protected $generator;
/**
*/
protected $chainQueue;
+ /**
+ * @var Validator
+ */
+ protected $validator;
/**
* UpdateCommand constructor.
Manager $extensionManager,
UpdateGenerator $generator,
Site $site,
- ChainQueue $chainQueue
+ ChainQueue $chainQueue,
+ Validator $validator
) {
$this->extensionManager = $extensionManager;
$this->generator = $generator;
$this->site = $site;
$this->chainQueue = $chainQueue;
+ $this->validator = $validator;
parent::__construct();
}
null,
InputOption::VALUE_REQUIRED,
$this->trans('commands.generate.update.options.update-n')
- );
+ )->setAliases(['gu']);
}
/**
*/
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;
}
);
}
- $this->generator->generate($module, $updateNumber);
+ $this->generator->generate([
+ 'module' => $module,
+ 'update_number' => $updateNumber,
+ ]);
$this->chainQueue->addCommand('cache:rebuild', ['cache' => 'discovery']);
protected function interact(InputInterface $input, OutputInterface $output)
{
- $io = new DrupalStyle($input, $output);
-
$this->site->loadLegacyFile('/core/includes/update.inc');
$this->site->loadLegacyFile('/core/includes/schema.inc');
- $module = $input->getOption('module');
- if (!$module) {
- // @see Drupal\Console\Command\Shared\ModuleTrait::moduleQuestion
- $module = $this->moduleQuestion($io);
- $input->setOption('module', $module);
- }
+ // --module option
+ $module = $this->getModuleOption();
$lastUpdateSchema = $this->getLastUpdate($module);
$nextUpdateSchema = $lastUpdateSchema ? ($lastUpdateSchema + 1): 8001;
$updateNumber = $input->getOption('update-n');
if (!$updateNumber) {
- $updateNumber = $io->ask(
+ $updateNumber = $this->getIo()->ask(
$this->trans('commands.generate.update.questions.update-n'),
$nextUpdateSchema,
function ($updateNumber) use ($lastUpdateSchema) {
}
}
-
- protected function createGenerator()
- {
- return new UpdateGenerator();
- }
-
protected function getLastUpdate($module)
{
$this->site->loadLegacyFile('/core/includes/update.inc');