ListAdminCommand.php 1.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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\Command;
  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 Command
  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->container->get('sonata_admin.admin.pool');
  27. $output->writeln("<info>Admin services:</info>");
  28. foreach ($pool->getAdminServiceIds() as $id) {
  29. $instance = $this->container->get($id);
  30. $output->writeln(sprintf(" <info>%-40s</info> %-60s",
  31. $id,
  32. $instance->getClass()
  33. ));
  34. }
  35. }
  36. }