ListAdminCommand.php 1.3 KB

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