ListAdminCommand.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <?php
  2. /*
  3. * This file is part of the Sonata 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. use Symfony\Component\Console\Output\Output;
  15. class ListAdminCommand extends ContainerAwareCommand
  16. {
  17. /**
  18. * {@inheritDoc}
  19. */
  20. public function configure()
  21. {
  22. $this->setName('sonata:admin:list');
  23. $this->setDescription('List all admin services available');
  24. }
  25. /**
  26. * {@inheritDoc}
  27. */
  28. public function execute(InputInterface $input, OutputInterface $output)
  29. {
  30. $pool = $this->getContainer()->get('sonata.admin.pool');
  31. $output->writeln("<info>Admin services:</info>");
  32. foreach ($pool->getAdminServiceIds() as $id) {
  33. $instance = $this->getContainer()->get($id);
  34. $output->writeln(sprintf(" <info>%-40s</info> %-60s",
  35. $id,
  36. $instance->getClass()
  37. ));
  38. }
  39. }
  40. }