Browse Source

add list admin command

Thomas Rabaix 14 years ago
parent
commit
e30bc9ee89
1 changed files with 44 additions and 0 deletions
  1. 44 0
      Command/ListAdminCommand.php

+ 44 - 0
Command/ListAdminCommand.php

@@ -0,0 +1,44 @@
+<?php
+
+/*
+ * This file is part of the Sonata package.
+ *
+ * (c) Thomas Rabaix <thomas.rabaix@sonata-project.org>
+ *
+ * For the full copyright and license information, please view the LICENSE
+ * file that was distributed with this source code.
+ */
+
+namespace Sonata\AdminBundle\Command;
+
+use Symfony\Bundle\FrameworkBundle\Command\Command;
+use Symfony\Component\Console\Input\InputArgument;
+use Symfony\Component\Console\Input\InputOption;
+use Symfony\Component\Console\Input\InputInterface;
+use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Console\Output\Output;
+
+class ListAdminCommand extends Command
+{
+
+    public function configure()
+    {
+        $this->setName('sonata:admin:list');
+        $this->setDescription('List all admin services available');
+    }
+
+    public function execute(InputInterface $input, OutputInterface $output)
+    {
+
+        $pool = $this->container->get('sonata_admin.admin.pool');
+
+        $output->writeln("<info>Admin services:</info>");
+        foreach ($pool->getAdminServiceIds() as $id) {
+            $instance = $this->container->get($id);
+            $output->writeln(sprintf("  <info>%-40s</info> %-60s",
+                $id,
+                $instance->getClass()
+            ));
+        }
+    }
+}