ListAdminCommand.php 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445
  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. class ListAdminCommand extends ContainerAwareCommand
  15. {
  16. /**
  17. * {@inheritdoc}
  18. */
  19. public function configure()
  20. {
  21. $this->setName('sonata:admin:list');
  22. $this->setDescription('List all admin services available');
  23. }
  24. /**
  25. * {@inheritdoc}
  26. */
  27. public function execute(InputInterface $input, OutputInterface $output)
  28. {
  29. $pool = $this->getContainer()->get('sonata.admin.pool');
  30. $output->writeln('<info>Admin services:</info>');
  31. foreach ($pool->getAdminServiceIds() as $id) {
  32. $instance = $this->getContainer()->get($id);
  33. $output->writeln(sprintf(' <info>%-40s</info> %-60s',
  34. $id,
  35. $instance->getClass()
  36. ));
  37. }
  38. }
  39. }