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\Command;
use Drupal\Core\Entity\EntityTypeManagerInterface;
-use Drupal\Console\Core\Command\Shared\CommandTrait;
-use Drupal\Console\Core\Style\DrupalStyle;
class StylesFlushCommand extends Command
{
- use CommandTrait;
-
/**
* @var EntityTypeManagerInterface
*/
'styles',
InputArgument::IS_ARRAY | InputArgument::REQUIRED,
$this->trans('commands.image.styles.flush.options.image-style')
- );
+ )->setAliases(['isf']);
}
/**
*/
protected function interact(InputInterface $input, OutputInterface $output)
{
- $io = new DrupalStyle($input, $output);
$styles = $input->getArgument('styles');
if (!$styles) {
$imageStyle = $this->entityTypeManager->getStorage('image_style');
$styleNames[] = $style->get('name');
}
- $styles = $io->choice(
+ $styles = $this->getIo()->choice(
$this->trans('commands.image.styles.flush.questions.image-style'),
$styleNames,
null,
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
- $io = new DrupalStyle($input, $output);
$styles = $input->getArgument('styles');
$result = 0;
foreach ($styles as $style) {
try {
- $io->info(
+ $this->getIo()->info(
sprintf(
$this->trans('commands.image.styles.flush.messages.executing-flush'),
$style
$imageStyle->load($style)->flush();
} catch (\Exception $e) {
watchdog_exception('image', $e);
- $io->error($e->getMessage());
+ $this->getIo()->error($e->getMessage());
$result = 1;
}
}
- $io->success($this->trans('commands.image.styles.flush.messages.success'));
+ $this->getIo()->success($this->trans('commands.image.styles.flush.messages.success'));
return $result;
}