use Symfony\Component\Console\Input\InputArgument;
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\Core\Entity\EntityTypeManagerInterface;
use Drupal\Core\Entity\Query\QueryFactory;
-use Drupal\Console\Core\Style\DrupalStyle;
/**
* Class DisableCommand
*/
class DisableCommand extends Command
{
- use CommandTrait;
-
/**
* @var EntityTypeManagerInterface
*/
->addArgument(
'view-id',
InputArgument::OPTIONAL,
- $this->trans('commands.views.debug.arguments.view-id')
- );
+ $this->trans('commands.debug.views.arguments.view-id')
+ )
+ ->setAliases(['vd']);
}
/**
*/
protected function interact(InputInterface $input, OutputInterface $output)
{
- $io = new DrupalStyle($input, $output);
$viewId = $input->getArgument('view-id');
if (!$viewId) {
$views = $this->entityQuery
->get('view')
->condition('status', 1)
->execute();
- $viewId = $io->choiceNoList(
- $this->trans('commands.views.debug.arguments.view-id'),
+ $viewId = $this->getIo()->choiceNoList(
+ $this->trans('commands.debug.views.arguments.view-id'),
$views
);
$input->setArgument('view-id', $viewId);
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
- $io = new DrupalStyle($input, $output);
-
$viewId = $input->getArgument('view-id');
$view = $this->entityTypeManager->getStorage('view')->load($viewId);
if (empty($view)) {
- $io->error(sprintf($this->trans('commands.views.debug.messages.not-found'), $viewId));
+ $this->getIo()->error(sprintf($this->trans('commands.debug.views.messages.not-found'), $viewId));
return 1;
}
try {
$view->disable()->save();
- $io->success(sprintf($this->trans('commands.views.disable.messages.disabled-successfully'), $view->get('label')));
+ $this->getIo()->success(sprintf($this->trans('commands.views.disable.messages.disabled-successfully'), $view->get('label')));
} catch (\Exception $e) {
- $io->error($e->getMessage());
+ $this->getIo()->error($e->getMessage());
return 1;
}