CachePoolListCommand.php 1.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364
  1. <?php
  2. /*
  3. * This file is part of the Symfony package.
  4. *
  5. * (c) Fabien Potencier <fabien@symfony.com>
  6. *
  7. * For the full copyright and license information, please view the LICENSE
  8. * file that was distributed with this source code.
  9. */
  10. namespace Symfony\Bundle\FrameworkBundle\Command;
  11. use Symfony\Component\Console\Command\Command;
  12. use Symfony\Component\Console\Input\InputInterface;
  13. use Symfony\Component\Console\Output\OutputInterface;
  14. use Symfony\Component\Console\Style\SymfonyStyle;
  15. /**
  16. * List available cache pools.
  17. *
  18. * @author Tobias Nyholm <tobias.nyholm@gmail.com>
  19. */
  20. final class CachePoolListCommand extends Command
  21. {
  22. protected static $defaultName = 'cache:pool:list';
  23. private $poolNames;
  24. public function __construct(array $poolNames)
  25. {
  26. parent::__construct();
  27. $this->poolNames = $poolNames;
  28. }
  29. /**
  30. * {@inheritdoc}
  31. */
  32. protected function configure()
  33. {
  34. $this
  35. ->setDescription('List available cache pools')
  36. ->setHelp(<<<'EOF'
  37. The <info>%command.name%</info> command lists all available cache pools.
  38. EOF
  39. )
  40. ;
  41. }
  42. /**
  43. * {@inheritdoc}
  44. */
  45. protected function execute(InputInterface $input, OutputInterface $output): int
  46. {
  47. $io = new SymfonyStyle($input, $output);
  48. $io->table(['Pool name'], array_map(function ($pool) {
  49. return [$pool];
  50. }, $this->poolNames));
  51. return 0;
  52. }
  53. }