X-Git-Url: http://aleph1.co.uk/gitweb/?a=blobdiff_plain;f=vendor%2Fdrupal%2Fconsole%2Fsrc%2FCommand%2FViews%2FDisableCommand.php;h=dbee8f139c27fd239be886fda0a2f55c800a4203;hb=9917807b03b64faf00f6a1f29dcb6eafc454efa5;hp=c127f649c10be3e396921c8fe0162f02882fcba6;hpb=a2bd1bf0c2c1f1a17d188f4dc0726a45494cefae;p=yaffs-website diff --git a/vendor/drupal/console/src/Command/Views/DisableCommand.php b/vendor/drupal/console/src/Command/Views/DisableCommand.php index c127f649c..dbee8f139 100644 --- a/vendor/drupal/console/src/Command/Views/DisableCommand.php +++ b/vendor/drupal/console/src/Command/Views/DisableCommand.php @@ -10,11 +10,9 @@ namespace Drupal\Console\Command\Views; 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 @@ -23,8 +21,6 @@ use Drupal\Console\Core\Style\DrupalStyle; */ class DisableCommand extends Command { - use CommandTrait; - /** * @var EntityTypeManagerInterface */ @@ -61,8 +57,9 @@ class DisableCommand extends Command ->addArgument( 'view-id', InputArgument::OPTIONAL, - $this->trans('commands.views.debug.arguments.view-id') - ); + $this->trans('commands.debug.views.arguments.view-id') + ) + ->setAliases(['vd']); } /** @@ -70,15 +67,14 @@ class DisableCommand extends Command */ 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); @@ -90,23 +86,26 @@ class DisableCommand extends Command */ 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)); - return; + $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; } + + return 0; } }