ListAdminCommand.php 1.3 KB

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