renamed Command to ContainerAwareCommand
This commit is contained in:
parent
5744b520f7
commit
25e99e894b
@ -9,6 +9,9 @@ timeline closely anyway.
|
||||
beta5 to RC1
|
||||
------------
|
||||
|
||||
* renamed `Symfony\Bundle\FrameworkBundle\Command\Command` to
|
||||
`Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand`
|
||||
|
||||
* removed the routing `AnnotGlobLoader` class
|
||||
|
||||
* Some blocks in the Twig Form templates have been renamed to avoid
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Bundle\DoctrineBundle\Command;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Command\Command;
|
||||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||
use Doctrine\ORM\Tools\EntityGenerator;
|
||||
|
||||
/**
|
||||
@ -19,7 +19,7 @@ use Doctrine\ORM\Tools\EntityGenerator;
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
abstract class DoctrineCommand extends Command
|
||||
abstract class DoctrineCommand extends ContainerAwareCommand
|
||||
{
|
||||
protected function getEntityGenerator()
|
||||
{
|
||||
@ -35,7 +35,7 @@ abstract class DoctrineCommand extends Command
|
||||
|
||||
protected function getEntityManager($name)
|
||||
{
|
||||
return $this->container->get('doctrine')->getEntityManager($name);
|
||||
return $this->getContainer()->get('doctrine')->getEntityManager($name);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -46,6 +46,6 @@ abstract class DoctrineCommand extends Command
|
||||
*/
|
||||
protected function getDoctrineConnection($name)
|
||||
{
|
||||
return $this->container->get('doctrine')->getConnection($name);
|
||||
return $this->getContainer()->get('doctrine')->getConnection($name);
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ EOT
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$manager = new DisconnectedMetadataFactory($this->container->get('doctrine'));
|
||||
$manager = new DisconnectedMetadataFactory($this->getContainer()->get('doctrine'));
|
||||
|
||||
try {
|
||||
$bundle = $this->getApplication()->getKernel()->getBundle($input->getArgument('name'));
|
||||
@ -82,7 +82,7 @@ EOT
|
||||
$name = strtr($input->getArgument('name'), '/', '\\');
|
||||
|
||||
if (false !== $pos = strpos($name, ':')) {
|
||||
$name = $this->container->get('doctrine')->getEntityNamespace(substr($name, 0, $pos)).'\\'.substr($name, $pos + 1);
|
||||
$name = $this->getContainer()->get('doctrine')->getEntityNamespace(substr($name, 0, $pos)).'\\'.substr($name, $pos + 1);
|
||||
}
|
||||
|
||||
if (class_exists($name)) {
|
||||
|
@ -79,7 +79,7 @@ EOT
|
||||
));
|
||||
|
||||
$entity = substr($entity, $pos + 1);
|
||||
$fullEntityClassName = $this->container->get('doctrine')->getEntityNamespace($bundleName).'\\'.$entity;
|
||||
$fullEntityClassName = $this->getContainer()->get('doctrine')->getEntityNamespace($bundleName).'\\'.$entity;
|
||||
$mappingType = $input->getOption('mapping-type');
|
||||
|
||||
$class = new ClassMetadataInfo($fullEntityClassName);
|
||||
|
@ -46,7 +46,7 @@ EOT
|
||||
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$entityManagerName = $input->getOption('em') ? $input->getOption('em') : $this->container->get('doctrine')->getDefaultEntityManagerName();
|
||||
$entityManagerName = $input->getOption('em') ? $input->getOption('em') : $this->getContainer()->get('doctrine')->getDefaultEntityManagerName();
|
||||
|
||||
/* @var $entityManager Doctrine\ORM\EntityManager */
|
||||
$entityManager = $this->getEntityManager($input->getOption('em'));
|
||||
|
@ -22,7 +22,7 @@ use Symfony\Component\Console\Output\Output;
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class AssetsInstallCommand extends Command
|
||||
class AssetsInstallCommand extends ContainerAwareCommand
|
||||
{
|
||||
/**
|
||||
* @see Command
|
||||
@ -67,12 +67,12 @@ EOT
|
||||
throw new \InvalidArgumentException('The symlink() function is not available on your system. You need to install the assets without the --symlink option.');
|
||||
}
|
||||
|
||||
$filesystem = $this->container->get('filesystem');
|
||||
$filesystem = $this->getContainer()->get('filesystem');
|
||||
|
||||
// Create the bundles directory otherwise symlink will fail.
|
||||
$filesystem->mkdir($input->getArgument('target').'/bundles/', 0777);
|
||||
|
||||
foreach ($this->container->get('kernel')->getBundles() as $bundle) {
|
||||
foreach ($this->getContainer()->get('kernel')->getBundles() as $bundle) {
|
||||
if (is_dir($originDir = $bundle->getPath().'/Resources/public')) {
|
||||
$targetDir = $input->getArgument('target').'/bundles/'.preg_replace('/bundle$/', '', strtolower($bundle->getName()));
|
||||
|
||||
|
@ -23,7 +23,7 @@ use Symfony\Component\Finder\Finder;
|
||||
* @author Francis Besset <francis.besset@gmail.com>
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class CacheClearCommand extends Command
|
||||
class CacheClearCommand extends ContainerAwareCommand
|
||||
{
|
||||
/**
|
||||
* @see Command
|
||||
@ -52,7 +52,7 @@ EOF
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$realCacheDir = $this->container->getParameter('kernel.cache_dir');
|
||||
$realCacheDir = $this->getContainer()->getParameter('kernel.cache_dir');
|
||||
$oldCacheDir = $realCacheDir.'_old';
|
||||
|
||||
if (!is_writable($realCacheDir)) {
|
||||
@ -70,14 +70,14 @@ EOF
|
||||
rename($warmupDir, $realCacheDir);
|
||||
}
|
||||
|
||||
$this->container->get('filesystem')->remove($oldCacheDir);
|
||||
$this->getContainer()->get('filesystem')->remove($oldCacheDir);
|
||||
}
|
||||
|
||||
protected function warmup($warmupDir)
|
||||
{
|
||||
$this->container->get('filesystem')->remove($warmupDir);
|
||||
$this->getContainer()->get('filesystem')->remove($warmupDir);
|
||||
|
||||
$kernel = $this->getTempKernel($this->container->get('kernel'), $warmupDir);
|
||||
$kernel = $this->getTempKernel($this->getContainer()->get('kernel'), $warmupDir);
|
||||
$kernel->boot();
|
||||
|
||||
$warmer = $kernel->getContainer()->get('cache_warmer');
|
||||
@ -131,7 +131,7 @@ namespace $namespace
|
||||
}
|
||||
}
|
||||
EOF;
|
||||
$this->container->get('filesystem')->mkdir($warmupDir);
|
||||
$this->getContainer()->get('filesystem')->mkdir($warmupDir);
|
||||
file_put_contents($file = $warmupDir.'/kernel.tmp', $code);
|
||||
require_once $file;
|
||||
@unlink($file);
|
||||
|
@ -19,7 +19,7 @@ use Symfony\Component\Console\Output\OutputInterface;
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class CacheWarmupCommand extends Command
|
||||
class CacheWarmupCommand extends ContainerAwareCommand
|
||||
{
|
||||
/**
|
||||
* @see Command
|
||||
@ -45,8 +45,8 @@ EOF
|
||||
{
|
||||
$output->writeln('Warming up the cache');
|
||||
|
||||
$warmer = $this->container->get('cache_warmer');
|
||||
$warmer = $this->getContainer()->get('cache_warmer');
|
||||
$warmer->enableOptionalWarmers();
|
||||
$warmer->warmUp($this->container->getParameter('kernel.cache_dir'));
|
||||
$warmer->warmUp($this->getContainer()->getParameter('kernel.cache_dir'));
|
||||
}
|
||||
}
|
||||
|
@ -1,37 +0,0 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\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;
|
||||
use Symfony\Component\Console\Command\Command as BaseCommand;
|
||||
|
||||
/**
|
||||
* Command.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
abstract class Command extends BaseCommand
|
||||
{
|
||||
/**
|
||||
* @var \Symfony\Component\DependencyInjection\ContainerInterface
|
||||
*/
|
||||
protected $container;
|
||||
|
||||
protected function initialize(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$this->container = $this->getApplication()->getKernel()->getContainer();
|
||||
}
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
/*
|
||||
* This file is part of the Symfony package.
|
||||
*
|
||||
* (c) Fabien Potencier <fabien@symfony.com>
|
||||
*
|
||||
* For the full copyright and license information, please view the LICENSE
|
||||
* file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
namespace Symfony\Bundle\FrameworkBundle\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;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
|
||||
|
||||
/**
|
||||
* Command.
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
abstract class ContainerAwareCommand extends Command implements ContainerAwareInterface
|
||||
{
|
||||
/**
|
||||
* @var ContainerInterface
|
||||
*/
|
||||
private $container;
|
||||
|
||||
protected function getContainer()
|
||||
{
|
||||
if (null === $this->container) {
|
||||
$this->container = $this->getApplication()->getKernel()->getContainer();
|
||||
}
|
||||
|
||||
return $this->container;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see ContainerAwareInterface::setContainer()
|
||||
*/
|
||||
public function setContainer(ContainerInterface $container = null)
|
||||
{
|
||||
$this->container = $container;
|
||||
}
|
||||
}
|
@ -27,7 +27,7 @@ use Symfony\Component\Config\FileLocator;
|
||||
*
|
||||
* @author Ryan Weaver <ryan@thatsquality.com>
|
||||
*/
|
||||
class ContainerDebugCommand extends Command
|
||||
class ContainerDebugCommand extends ContainerAwareCommand
|
||||
{
|
||||
/**
|
||||
* @var ContainerBuilder
|
||||
@ -183,7 +183,7 @@ EOF
|
||||
throw new \LogicException(sprintf('Debug information about the container is only available in debug mode.'));
|
||||
}
|
||||
|
||||
if (!file_exists($cachedFile = $this->container->getParameter('debug.container.dump'))) {
|
||||
if (!file_exists($cachedFile = $this->getContainer()->getParameter('debug.container.dump'))) {
|
||||
throw new \LogicException(sprintf('Debug information about the container could not be found. Please clear the cache and try again.'));
|
||||
}
|
||||
|
||||
|
@ -23,7 +23,7 @@ use Symfony\Bundle\FrameworkBundle\Generator\Generator;
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class InitBundleCommand extends Command
|
||||
class InitBundleCommand extends ContainerAwareCommand
|
||||
{
|
||||
/**
|
||||
* @see Command
|
||||
@ -101,7 +101,7 @@ EOT
|
||||
throw new \RuntimeException(sprintf('Bundle "%s" already exists.', $bundle));
|
||||
}
|
||||
|
||||
$filesystem = $this->container->get('filesystem');
|
||||
$filesystem = $this->getContainer()->get('filesystem');
|
||||
$filesystem->mirror(__DIR__.'/../Resources/skeleton/bundle/generic', $targetDir);
|
||||
$filesystem->mirror(__DIR__.'/../Resources/skeleton/bundle/'.$input->getOption('format'), $targetDir);
|
||||
|
||||
|
@ -23,7 +23,7 @@ use Symfony\Component\Routing\Matcher\Dumper\ApacheMatcherDumper;
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class RouterApacheDumperCommand extends Command
|
||||
class RouterApacheDumperCommand extends ContainerAwareCommand
|
||||
{
|
||||
/**
|
||||
* @see Command
|
||||
@ -53,7 +53,7 @@ EOF
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$router = $this->container->get('router');
|
||||
$router = $this->getContainer()->get('router');
|
||||
|
||||
$dumpOptions = array();
|
||||
if ($input->getArgument('script_name')) {
|
||||
|
@ -23,7 +23,7 @@ use Symfony\Component\Routing\Matcher\Dumper\ApacheMatcherDumper;
|
||||
*
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
*/
|
||||
class RouterDebugCommand extends Command
|
||||
class RouterDebugCommand extends ContainerAwareCommand
|
||||
{
|
||||
/**
|
||||
* @see Command
|
||||
@ -50,7 +50,7 @@ EOF
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$router = $this->container->get('router');
|
||||
$router = $this->getContainer()->get('router');
|
||||
|
||||
$routes = array();
|
||||
foreach ($router->getRouteCollection()->all() as $name => $route) {
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Bundle\SecurityBundle\Command;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Command\Command;
|
||||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||
use Symfony\Component\Security\Acl\Dbal\Schema;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
@ -39,15 +39,15 @@ class InitAclCommand extends Command
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$connection = $this->container->get('security.acl.dbal.connection');
|
||||
$connection = $this->getContainer()->get('security.acl.dbal.connection');
|
||||
$sm = $connection->getSchemaManager();
|
||||
$tableNames = $sm->listTableNames();
|
||||
$tables = array(
|
||||
'class_table_name' => $this->container->getParameter('security.acl.dbal.class_table_name'),
|
||||
'sid_table_name' => $this->container->getParameter('security.acl.dbal.sid_table_name'),
|
||||
'oid_table_name' => $this->container->getParameter('security.acl.dbal.oid_table_name'),
|
||||
'oid_ancestors_table_name' => $this->container->getParameter('security.acl.dbal.oid_ancestors_table_name'),
|
||||
'entry_table_name' => $this->container->getParameter('security.acl.dbal.entry_table_name'),
|
||||
'class_table_name' => $this->getContainer()->getParameter('security.acl.dbal.class_table_name'),
|
||||
'sid_table_name' => $this->getContainer()->getParameter('security.acl.dbal.sid_table_name'),
|
||||
'oid_table_name' => $this->getContainer()->getParameter('security.acl.dbal.oid_table_name'),
|
||||
'oid_ancestors_table_name' => $this->getContainer()->getParameter('security.acl.dbal.oid_ancestors_table_name'),
|
||||
'entry_table_name' => $this->getContainer()->getParameter('security.acl.dbal.entry_table_name'),
|
||||
);
|
||||
|
||||
foreach ($tables as $table) {
|
||||
|
@ -11,7 +11,7 @@
|
||||
|
||||
namespace Symfony\Bundle\SwiftmailerBundle\Command;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Command\Command;
|
||||
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
use Symfony\Component\Console\Input\InputOption;
|
||||
@ -22,7 +22,7 @@ use Symfony\Component\Console\Input\InputOption;
|
||||
* @author Fabien Potencier <fabien@symfony.com>
|
||||
* @author Clément JOBEILI <clement.jobeili@gmail.com>
|
||||
*/
|
||||
class SendEmailCommand extends Command
|
||||
class SendEmailCommand extends ContainerAwareCommand
|
||||
{
|
||||
/**
|
||||
* @see Command
|
||||
@ -49,14 +49,14 @@ EOF
|
||||
*/
|
||||
protected function execute(InputInterface $input, OutputInterface $output)
|
||||
{
|
||||
$mailer = $this->container->get('mailer');
|
||||
$mailer = $this->getContainer()->get('mailer');
|
||||
$transport = $mailer->getTransport();
|
||||
|
||||
if ($transport instanceof \Swift_Transport_SpoolTransport) {
|
||||
$spool = $transport->getSpool();
|
||||
$spool->setMessageLimit($input->getOption('message-limit'));
|
||||
$spool->setTimeLimit($input->getOption('time-limit'));
|
||||
$sent = $spool->flushQueue($this->container->get('swiftmailer.transport.real'));
|
||||
$sent = $spool->flushQueue($this->getContainer()->get('swiftmailer.transport.real'));
|
||||
|
||||
$output->writeln(sprintf('sent %s emails', $sent));
|
||||
}
|
||||
|
Reference in New Issue
Block a user