Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Updated commands to use the new ContainerAwareCommand instead #161

Merged
merged 2 commits into from Jun 21, 2011
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions Command/ExplainAdminCommand.php
Expand Up @@ -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()
Expand All @@ -32,7 +32,7 @@ public function configure()
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()));
Expand Down Expand Up @@ -75,7 +75,7 @@ public function execute(InputInterface $input, OutputInterface $output)
$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('');
Expand Down
8 changes: 4 additions & 4 deletions Command/ListAdminCommand.php
Expand Up @@ -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()
Expand All @@ -29,11 +29,11 @@ public function configure()

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()
Expand Down
10 changes: 5 additions & 5 deletions Command/SetupAclCommand.php
Expand Up @@ -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;
Expand All @@ -26,7 +26,7 @@
use Symfony\Component\Security\Acl\Domain\ObjectIdentity;
use Sonata\AdminBundle\Security\Handler\AclSecurityHandler;

class SetupAclCommand extends Command
class SetupAclCommand extends ContainerAwareCommand
{
public function configure()
{
Expand All @@ -36,16 +36,16 @@ public function configure()

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()));
Expand Down