浏览代码

Merge pull request #161 from simpler/master

Updated commands to use the new ContainerAwareCommand instead
Thomas 14 年之前
父节点
当前提交
2ce5fee709
共有 3 个文件被更改,包括 13 次插入13 次删除
  1. 4 4
      Command/ExplainAdminCommand.php
  2. 4 4
      Command/ListAdminCommand.php
  3. 5 5
      Command/SetupAclCommand.php

+ 4 - 4
Command/ExplainAdminCommand.php

@@ -11,14 +11,14 @@
 
 namespace Sonata\AdminBundle\Command;
 
-use Symfony\Bundle\FrameworkBundle\Command\Command;
+use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
 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 ExplainAdminCommand extends Command
+class ExplainAdminCommand extends ContainerAwareCommand
 {
 
     public function configure()
@@ -32,7 +32,7 @@ class ExplainAdminCommand extends Command
     public function execute(InputInterface $input, OutputInterface $output)
     {
 
-        $admin = $this->container->get($input->getArgument('admin'));
+        $admin = $this->getContainer()->get($input->getArgument('admin'));
 
         $output->writeln('<comment>AdminBundle Information</comment>');
         $output->writeln(sprintf('<info>% -20s</info> : %s', 'id', $admin->getCode()));
@@ -75,7 +75,7 @@ class ExplainAdminCommand extends Command
             $output->writeln(sprintf('  - % -25s  % -15s % -15s', $name, $fieldDescription->getType(), $fieldDescription->getTemplate()));
         }
 
-        $validatorFactory = $this->container->get('validator.mapping.class_metadata_factory');
+        $validatorFactory = $this->getContainer()->get('validator.mapping.class_metadata_factory');
         $metadata = $validatorFactory->getClassMetadata($admin->getClass());
 
         $output->writeln('');

+ 4 - 4
Command/ListAdminCommand.php

@@ -11,14 +11,14 @@
 
 namespace Sonata\AdminBundle\Command;
 
-use Symfony\Bundle\FrameworkBundle\Command\Command;
+use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
 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
+class ListAdminCommand extends ContainerAwareCommand
 {
 
     public function configure()
@@ -29,11 +29,11 @@ class ListAdminCommand extends Command
 
     public function execute(InputInterface $input, OutputInterface $output)
     {
-        $pool = $this->container->get('sonata.admin.pool');
+        $pool = $this->getContainer()->get('sonata.admin.pool');
 
         $output->writeln("<info>Admin services:</info>");
         foreach ($pool->getAdminServiceIds() as $id) {
-            $instance = $this->container->get($id);
+            $instance = $this->getContainer()->get($id);
             $output->writeln(sprintf("  <info>%-40s</info> %-60s",
                 $id,
                 $instance->getClass()

+ 5 - 5
Command/SetupAclCommand.php

@@ -11,7 +11,7 @@
 
 namespace Sonata\AdminBundle\Command;
 
-use Symfony\Bundle\FrameworkBundle\Command\Command;
+use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
 use Symfony\Component\Console\Input\InputArgument;
 use Symfony\Component\Console\Input\InputOption;
 use Symfony\Component\Console\Input\InputInterface;
@@ -26,7 +26,7 @@ use Symfony\Component\Security\Acl\Exception\AclNotFoundException;
 use Symfony\Component\Security\Acl\Domain\ObjectIdentity;
 use Sonata\AdminBundle\Security\Handler\AclSecurityHandler;
 
-class SetupAclCommand extends Command
+class SetupAclCommand extends ContainerAwareCommand
 {
     public function configure()
     {
@@ -36,16 +36,16 @@ class SetupAclCommand extends Command
 
     public function execute(InputInterface $input, OutputInterface $output)
     {
-        $aclProvider = $this->container->get('security.acl.provider');
+        $aclProvider = $this->getContainer()->get('security.acl.provider');
 
         $output->writeln('Starting ACL AdminBundle configuration');
 
         $builder = new MaskBuilder();
-        foreach ($this->container->get('sonata.admin.pool')->getAdminServiceIds() as $id) {
+        foreach ($this->getContainer()->get('sonata.admin.pool')->getAdminServiceIds() as $id) {
             $output->writeln(sprintf(' > install ACL for %s', $id));
 
             try {
-                $admin = $this->container->get($id);
+                $admin = $this->getContainer()->get($id);
             } catch (\Exception $e) {
                 $output->writeln('<error>Warning : The admin class cannot be initiated from the command line</error>');
                 $output->writeln(sprintf('<error>%s</error>', $e->getMessage()));