ListAdminCommand.php 1.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?php
  2. /*
  3. * This file is part of the Sonata Project package.
  4. *
  5. * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
  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 Sonata\AdminBundle\Command;
  11. use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
  12. use Symfony\Component\Console\Input\InputInterface;
  13. use Symfony\Component\Console\Output\OutputInterface;
  14. /**
  15. * @author Thomas Rabaix <thomas.rabaix@sonata-project.org>
  16. */
  17. class ListAdminCommand extends ContainerAwareCommand
  18. {
  19. /**
  20. * {@inheritdoc}
  21. */
  22. public function configure()
  23. {
  24. $this->setName('sonata:admin:list');
  25. $this->setDescription('List all admin services available');
  26. }
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public function execute(InputInterface $input, OutputInterface $output)
  31. {
  32. $pool = $this->getContainer()->get('sonata.admin.pool');
  33. $output->writeln('<info>Admin services:</info>');
  34. foreach ($pool->getAdminServiceIds() as $id) {
  35. $instance = $this->getContainer()->get($id);
  36. $output->writeln(sprintf(' <info>%-40s</info> %-60s',
  37. $id,
  38. $instance->getClass()
  39. ));
  40. }
  41. }
  42. }