diff --git a/src/Symfony/Bridge/Twig/Command/DebugCommand.php b/src/Symfony/Bridge/Twig/Command/DebugCommand.php
index e9519adb66d33..0c68c637f8c52 100644
--- a/src/Symfony/Bridge/Twig/Command/DebugCommand.php
+++ b/src/Symfony/Bridge/Twig/Command/DebugCommand.php
@@ -33,16 +33,16 @@ class DebugCommand extends Command
*/
public function __construct($twig = null)
{
- parent::__construct();
-
if (!$twig instanceof Environment) {
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
- $this->setName(null === $twig ? 'debug:twig' : $twig);
+ parent::__construct($twig);
return;
}
+ parent::__construct();
+
$this->twig = $twig;
}
diff --git a/src/Symfony/Bridge/Twig/Command/LintCommand.php b/src/Symfony/Bridge/Twig/Command/LintCommand.php
index 2aae6120d318f..f96da4d615a29 100644
--- a/src/Symfony/Bridge/Twig/Command/LintCommand.php
+++ b/src/Symfony/Bridge/Twig/Command/LintCommand.php
@@ -38,16 +38,16 @@ class LintCommand extends Command
*/
public function __construct($twig = null)
{
- parent::__construct();
-
if (!$twig instanceof Environment) {
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
- $this->setName(null === $twig ? 'lint:twig' : $twig);
+ parent::__construct($twig);
return;
}
+ parent::__construct();
+
$this->twig = $twig;
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php
index b8ad74300d759..ffc770c7a5a69 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Command/AssetsInstallCommand.php
@@ -42,16 +42,16 @@ class AssetsInstallCommand extends ContainerAwareCommand
*/
public function __construct($filesystem = null)
{
- parent::__construct();
-
if (!$filesystem instanceof Filesystem) {
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
- $this->setName(null === $filesystem ? 'assets:install' : $filesystem);
+ parent::__construct($filesystem);
return;
}
+ parent::__construct();
+
$this->filesystem = $filesystem;
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php
index 631b31b600a27..c3a7bf450ed0f 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Command/CacheClearCommand.php
@@ -39,16 +39,16 @@ class CacheClearCommand extends ContainerAwareCommand
*/
public function __construct($cacheClearer = null, Filesystem $filesystem = null)
{
- parent::__construct();
-
if (!$cacheClearer instanceof CacheClearerInterface) {
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
- $this->setName(null === $cacheClearer ? 'cache:clear' : $cacheClearer);
+ parent::__construct($cacheClearer);
return;
}
+ parent::__construct();
+
$this->cacheClearer = $cacheClearer;
$this->filesystem = $filesystem ?: new Filesystem();
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolClearCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolClearCommand.php
index 60c42e8729b13..fec933f67b9ce 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolClearCommand.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Command/CachePoolClearCommand.php
@@ -32,16 +32,16 @@ final class CachePoolClearCommand extends ContainerAwareCommand
*/
public function __construct($poolClearer = null)
{
- parent::__construct();
-
if (!$poolClearer instanceof Psr6CacheClearer) {
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
- $this->setName(null === $poolClearer ? 'cache:pool:clear' : $poolClearer);
+ parent::__construct($poolClearer);
return;
}
+ parent::__construct();
+
$this->poolClearer = $poolClearer;
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php
index 0f72db83052e9..57972782dc771 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Command/CacheWarmupCommand.php
@@ -33,16 +33,16 @@ class CacheWarmupCommand extends ContainerAwareCommand
*/
public function __construct($cacheWarmer = null)
{
- parent::__construct();
-
if (!$cacheWarmer instanceof CacheWarmerAggregate) {
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
- $this->setName(null === $cacheWarmer ? 'cache:warmup' : $cacheWarmer);
+ parent::__construct($cacheWarmer);
return;
}
+ parent::__construct();
+
$this->cacheWarmer = $cacheWarmer;
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/EventDispatcherDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/EventDispatcherDebugCommand.php
index d2f8bd77751b5..18aa08575c4e0 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Command/EventDispatcherDebugCommand.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Command/EventDispatcherDebugCommand.php
@@ -35,16 +35,16 @@ class EventDispatcherDebugCommand extends ContainerAwareCommand
*/
public function __construct($dispatcher = null)
{
- parent::__construct();
-
if (!$dispatcher instanceof EventDispatcherInterface) {
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
- $this->setName(null === $dispatcher ? 'debug:event-dispatcher' : $dispatcher);
+ parent::__construct($dispatcher);
return;
}
+ parent::__construct();
+
$this->dispatcher = $dispatcher;
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php
index 253f9a13f29a4..2a005090322dd 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Command/RouterDebugCommand.php
@@ -39,16 +39,16 @@ class RouterDebugCommand extends ContainerAwareCommand
*/
public function __construct($router = null)
{
- parent::__construct();
-
if (!$router instanceof RouterInterface) {
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
- $this->setName(null === $router ? 'debug:router' : $router);
+ parent::__construct($router);
return;
}
+ parent::__construct();
+
$this->router = $router;
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php
index c6d2bdbf990cf..f88d2a2dfe0c7 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Command/RouterMatchCommand.php
@@ -36,16 +36,16 @@ class RouterMatchCommand extends ContainerAwareCommand
*/
public function __construct($router = null)
{
- parent::__construct();
-
if (!$router instanceof RouterInterface) {
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
- $this->setName(null === $router ? 'router:match' : $router);
+ parent::__construct($router);
return;
}
+ parent::__construct();
+
$this->router = $router;
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php
index 44730737bc8a7..f8e69a3c4a640 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php
@@ -36,14 +36,14 @@
*/
class TranslationDebugCommand extends ContainerAwareCommand
{
- private $translator;
- private $loader;
- private $extractor;
-
const MESSAGE_MISSING = 0;
const MESSAGE_UNUSED = 1;
const MESSAGE_EQUALS_FALLBACK = 2;
+ private $translator;
+ private $loader;
+ private $extractor;
+
/**
* @param TranslatorInterface $translator
* @param TranslationLoader $loader
@@ -51,16 +51,16 @@ class TranslationDebugCommand extends ContainerAwareCommand
*/
public function __construct($translator = null, TranslationLoader $loader = null, ExtractorInterface $extractor = null)
{
- parent::__construct();
-
if (!$translator instanceof TranslatorInterface) {
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
- $this->setName(null === $translator ? 'debug:translation' : $translator);
+ parent::__construct($translator);
return;
}
+ parent::__construct();
+
$this->translator = $translator;
$this->loader = $loader;
$this->extractor = $extractor;
diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php
index a02cb23a57547..357902a209305 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationUpdateCommand.php
@@ -46,16 +46,16 @@ class TranslationUpdateCommand extends ContainerAwareCommand
*/
public function __construct($writer = null, TranslationLoader $loader = null, ExtractorInterface $extractor = null, $defaultLocale = null)
{
- parent::__construct();
-
if (!$writer instanceof TranslationWriter) {
@trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
- $this->setName(null === $writer ? 'translation:update' : $writer);
+ parent::__construct($writer);
return;
}
+ parent::__construct();
+
$this->writer = $writer;
$this->loader = $loader;
$this->extractor = $extractor;
diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/XliffLintCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/XliffLintCommand.php
index 8f4739a9f8e80..36876dee24252 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Command/XliffLintCommand.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Command/XliffLintCommand.php
@@ -11,9 +11,6 @@
namespace Symfony\Bundle\FrameworkBundle\Command;
-use Symfony\Component\Console\Command\Command;
-use Symfony\Component\Console\Input\InputInterface;
-use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Translation\Command\XliffLintCommand as BaseLintCommand;
/**
@@ -25,39 +22,41 @@
*
* @final since version 3.4
*/
-class XliffLintCommand extends Command
+class XliffLintCommand extends BaseLintCommand
{
- private $command;
-
- /**
- * {@inheritdoc}
- */
- protected function configure()
+ public function __construct($name = null, $directoryIteratorProvider = null, $isReadableProvider = null)
{
- $this->setName('lint:xliff');
-
- if (!$this->isEnabled()) {
- return;
+ if (func_num_args()) {
+ @trigger_error(sprintf('Passing a constructor argument in "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
}
- $directoryIteratorProvider = function ($directory, $default) {
- if (!is_dir($directory)) {
- $directory = $this->getApplication()->getKernel()->locateResource($directory);
- }
+ if (null === $directoryIteratorProvider) {
+ $directoryIteratorProvider = function ($directory, $default) {
+ if (!is_dir($directory)) {
+ $directory = $this->getApplication()->getKernel()->locateResource($directory);
+ }
- return $default($directory);
- };
+ return $default($directory);
+ };
+ }
+
+ if (null === $isReadableProvider) {
+ $isReadableProvider = function ($fileOrDirectory, $default) {
+ return 0 === strpos($fileOrDirectory, '@') || $default($fileOrDirectory);
+ };
+ }
- $isReadableProvider = function ($fileOrDirectory, $default) {
- return 0 === strpos($fileOrDirectory, '@') || $default($fileOrDirectory);
- };
+ parent::__construct($name, $directoryIteratorProvider, $isReadableProvider);
+ }
- $this->command = new BaseLintCommand(null, $directoryIteratorProvider, $isReadableProvider);
+ /**
+ * {@inheritdoc}
+ */
+ protected function configure()
+ {
+ parent::configure();
- $this
- ->setDescription($this->command->getDescription())
- ->setDefinition($this->command->getDefinition())
- ->setHelp($this->command->getHelp().<<<'EOF'
+ $this->setHelp($this->getHelp().<<<'EOF'
Or find all files in a bundle:
@@ -66,17 +65,4 @@ protected function configure()
EOF
);
}
-
- /**
- * {@inheritdoc}
- */
- public function isEnabled()
- {
- return class_exists(BaseLintCommand::class);
- }
-
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- return $this->command->execute($input, $output);
- }
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php b/src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php
index 6e8f7dbfaeab8..f6c1a7f85b190 100644
--- a/src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php
+++ b/src/Symfony/Bundle/FrameworkBundle/Command/YamlLintCommand.php
@@ -11,9 +11,6 @@
namespace Symfony\Bundle\FrameworkBundle\Command;
-use Symfony\Component\Console\Command\Command;
-use Symfony\Component\Console\Input\InputInterface;
-use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Yaml\Command\LintCommand as BaseLintCommand;
/**
@@ -24,39 +21,41 @@
*
* @final since version 3.4
*/
-class YamlLintCommand extends Command
+class YamlLintCommand extends BaseLintCommand
{
- private $command;
-
- /**
- * {@inheritdoc}
- */
- protected function configure()
+ public function __construct($name = null, $directoryIteratorProvider = null, $isReadableProvider = null)
{
- $this->setName('lint:yaml');
-
- if (!$this->isEnabled()) {
- return;
+ if (func_num_args()) {
+ @trigger_error(sprintf('Passing a constructor argument in "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
}
- $directoryIteratorProvider = function ($directory, $default) {
- if (!is_dir($directory)) {
- $directory = $this->getApplication()->getKernel()->locateResource($directory);
- }
+ if (null === $directoryIteratorProvider) {
+ $directoryIteratorProvider = function ($directory, $default) {
+ if (!is_dir($directory)) {
+ $directory = $this->getApplication()->getKernel()->locateResource($directory);
+ }
- return $default($directory);
- };
+ return $default($directory);
+ };
+ }
+
+ if (null === $isReadableProvider) {
+ $isReadableProvider = function ($fileOrDirectory, $default) {
+ return 0 === strpos($fileOrDirectory, '@') || $default($fileOrDirectory);
+ };
+ }
- $isReadableProvider = function ($fileOrDirectory, $default) {
- return 0 === strpos($fileOrDirectory, '@') || $default($fileOrDirectory);
- };
+ parent::__construct($name, $directoryIteratorProvider, $isReadableProvider);
+ }
- $this->command = new BaseLintCommand(null, $directoryIteratorProvider, $isReadableProvider);
+ /**
+ * {@inheritdoc}
+ */
+ protected function configure()
+ {
+ parent::configure();
- $this
- ->setDescription($this->command->getDescription())
- ->setDefinition($this->command->getDefinition())
- ->setHelp($this->command->getHelp().<<<'EOF'
+ $this->setHelp($this->getHelp().<<<'EOF'
Or find all files in a bundle:
@@ -65,17 +64,4 @@ protected function configure()
EOF
);
}
-
- /**
- * {@inheritdoc}
- */
- public function isEnabled()
- {
- return class_exists(BaseLintCommand::class) && parent::isEnabled();
- }
-
- protected function execute(InputInterface $input, OutputInterface $output)
- {
- return $this->command->execute($input, $output);
- }
}
diff --git a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
index 65b28ec398120..14e6808278d0b 100644
--- a/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
+++ b/src/Symfony/Bundle/FrameworkBundle/DependencyInjection/FrameworkExtension.php
@@ -18,6 +18,8 @@
use Symfony\Bundle\FrameworkBundle\Command\TranslationDebugCommand;
use Symfony\Bundle\FrameworkBundle\Command\TranslationUpdateCommand;
use Symfony\Bundle\FrameworkBundle\Command\WorkflowDumpCommand;
+use Symfony\Bundle\FrameworkBundle\Command\XliffLintCommand;
+use Symfony\Bundle\FrameworkBundle\Command\YamlLintCommand;
use Symfony\Bundle\FrameworkBundle\Controller\AbstractController;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
use Symfony\Bundle\FrameworkBundle\Routing\AnnotatedRouteControllerLoader;
@@ -69,10 +71,12 @@
use Symfony\Component\Serializer\Normalizer\JsonSerializableNormalizer;
use Symfony\Component\Serializer\Normalizer\NormalizerInterface;
use Symfony\Component\Stopwatch\Stopwatch;
+use Symfony\Component\Translation\Command\XliffLintCommand as BaseXliffLintCommand;
use Symfony\Component\Validator\ConstraintValidatorInterface;
use Symfony\Component\Validator\ObjectInitializerInterface;
use Symfony\Component\WebLink\HttpHeaderSerializer;
use Symfony\Component\Workflow;
+use Symfony\Component\Yaml\Command\LintCommand as BaseYamlLintCommand;
/**
* FrameworkExtension.
@@ -128,6 +132,13 @@ public function load(array $configs, ContainerBuilder $container)
if (class_exists(Application::class)) {
$loader->load('console.xml');
+
+ if (!class_exists(BaseXliffLintCommand::class)) {
+ $container->removeDefinition(XliffLintCommand::class);
+ }
+ if (!class_exists(BaseYamlLintCommand::class)) {
+ $container->removeDefinition(YamlLintCommand::class);
+ }
}
// Property access is used by both the Form and the Validator component
diff --git a/src/Symfony/Bundle/SecurityBundle/Command/InitAclCommand.php b/src/Symfony/Bundle/SecurityBundle/Command/InitAclCommand.php
index 1512e910c9744..597df8ceb9de1 100644
--- a/src/Symfony/Bundle/SecurityBundle/Command/InitAclCommand.php
+++ b/src/Symfony/Bundle/SecurityBundle/Command/InitAclCommand.php
@@ -14,6 +14,8 @@
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
+use Symfony\Component\Security\Acl\Dbal\Schema;
+use Doctrine\DBAL\Connection;
use Doctrine\DBAL\Schema\SchemaException;
/**
@@ -25,12 +27,37 @@
*/
class InitAclCommand extends ContainerAwareCommand
{
+ private $connection;
+ private $schema;
+
+ /**
+ * @param Connection $connection
+ * @param Schema $schema
+ */
+ public function __construct($connection = null, Schema $schema = null)
+ {
+ if (!$connection instanceof Connection) {
+ @trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
+
+ parent::__construct($connection);
+
+ return;
+ }
+
+ parent::__construct();
+
+ $this->connection = $connection;
+ $this->schema = $schema;
+ }
+
/**
* {@inheritdoc}
+ *
+ * BC to be removed in 4.0
*/
public function isEnabled()
{
- if (!$this->getContainer()->has('security.acl.dbal.connection')) {
+ if (!$this->connection && !$this->getContainer()->has('security.acl.dbal.connection')) {
return false;
}
@@ -65,21 +92,22 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
- $container = $this->getContainer();
-
- $connection = $container->get('security.acl.dbal.connection');
- $schema = $container->get('security.acl.dbal.schema');
+ // BC to be removed in 4.0
+ if (null === $this->connection) {
+ $this->connection = $this->getContainer()->get('security.acl.dbal.connection');
+ $this->schema = $this->getContainer()->get('security.acl.dbal.schema');
+ }
try {
- $schema->addToSchema($connection->getSchemaManager()->createSchema());
+ $this->schema->addToSchema($this->connection->getSchemaManager()->createSchema());
} catch (SchemaException $e) {
$output->writeln('Aborting: '.$e->getMessage());
return 1;
}
- foreach ($schema->toSql($connection->getDatabasePlatform()) as $sql) {
- $connection->exec($sql);
+ foreach ($this->schema->toSql($this->connection->getDatabasePlatform()) as $sql) {
+ $this->connection->exec($sql);
}
$output->writeln('ACL tables have been initialized successfully.');
diff --git a/src/Symfony/Bundle/SecurityBundle/Command/SetAclCommand.php b/src/Symfony/Bundle/SecurityBundle/Command/SetAclCommand.php
index 7d0146fdc63de..840e74edfba87 100644
--- a/src/Symfony/Bundle/SecurityBundle/Command/SetAclCommand.php
+++ b/src/Symfony/Bundle/SecurityBundle/Command/SetAclCommand.php
@@ -32,11 +32,36 @@
*/
class SetAclCommand extends ContainerAwareCommand
{
+ private $provider;
+
+ /**
+ * @param MutableAclProviderInterface $provider
+ */
+ public function __construct($provider = null)
+ {
+ if (!$provider instanceof MutableAclProviderInterface) {
+ @trigger_error(sprintf('Passing a command name as the first argument of "%s" is deprecated since version 3.4 and will be removed in 4.0. If the command was registered by convention, make it a service instead.', __METHOD__), E_USER_DEPRECATED);
+
+ parent::__construct($provider);
+
+ return;
+ }
+
+ parent::__construct();
+
+ $this->provider = $provider;
+ }
+
/**
* {@inheritdoc}
+ *
+ * BC to be removed in 4.0
*/
public function isEnabled()
{
+ if (null !== $this->provider) {
+ return parent::isEnabled();
+ }
if (!$this->getContainer()->has('security.acl.provider')) {
return false;
}
@@ -91,6 +116,11 @@ protected function configure()
*/
protected function execute(InputInterface $input, OutputInterface $output)
{
+ // BC to be removed in 4.0
+ if (null === $this->provider) {
+ $this->provider = $this->getContainer()->get('security.acl.provider');
+ }
+
// Parse arguments
$objectIdentities = array();
$maskBuilder = $this->getMaskBuilder();
@@ -136,20 +166,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
}
- /** @var $container \Symfony\Component\DependencyInjection\ContainerInterface */
- $container = $this->getContainer();
- /** @var $aclProvider MutableAclProviderInterface */
- $aclProvider = $container->get('security.acl.provider');
-
// Sets ACL
foreach ($objectIdentities as $objectIdentity) {
// Creates a new ACL if it does not already exist
try {
- $aclProvider->createAcl($objectIdentity);
+ $this->provider->createAcl($objectIdentity);
} catch (AclAlreadyExistsException $e) {
}
- $acl = $aclProvider->findAcl($objectIdentity, $securityIdentities);
+ $acl = $this->provider->findAcl($objectIdentity, $securityIdentities);
foreach ($securityIdentities as $securityIdentity) {
if ($classScopeOption) {
@@ -159,13 +184,15 @@ protected function execute(InputInterface $input, OutputInterface $output)
}
}
- $aclProvider->updateAcl($acl);
+ $this->provider->updateAcl($acl);
}
}
/**
* Gets the mask builder.
*
+ * BC to be removed in 4.0
+ *
* @return MaskBuilder
*/
protected function getMaskBuilder()
diff --git a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php
index 4a77c13b48e76..dffe9d36879b2 100644
--- a/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php
+++ b/src/Symfony/Bundle/SecurityBundle/DependencyInjection/SecurityExtension.php
@@ -11,6 +11,8 @@
namespace Symfony\Bundle\SecurityBundle\DependencyInjection;
+use Symfony\Bundle\SecurityBundle\Command\InitAclCommand;
+use Symfony\Bundle\SecurityBundle\Command\SetAclCommand;
use Symfony\Bundle\SecurityBundle\Command\UserPasswordEncoderCommand;
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\Factory\SecurityFactoryInterface;
use Symfony\Bundle\SecurityBundle\DependencyInjection\Security\UserProvider\UserProviderFactoryInterface;
@@ -114,6 +116,9 @@ public function load(array $configs, ContainerBuilder $container)
// load ACL
if (isset($config['acl'])) {
$this->aclLoad($config['acl'], $container);
+ } else {
+ $container->removeDefinition(InitAclCommand::class);
+ $container->removeDefinition(SetAclCommand::class);
}
$container->registerForAutoconfiguration(VoterInterface::class)
diff --git a/src/Symfony/Bundle/SecurityBundle/Resources/config/console.xml b/src/Symfony/Bundle/SecurityBundle/Resources/config/console.xml
index f14b4a5a350dc..b375d95effe5c 100644
--- a/src/Symfony/Bundle/SecurityBundle/Resources/config/console.xml
+++ b/src/Symfony/Bundle/SecurityBundle/Resources/config/console.xml
@@ -8,10 +8,13 @@
+
+
+
diff --git a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SetAclCommandTest.php b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SetAclCommandTest.php
index 3b060a86fc242..1ceaca1002019 100644
--- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SetAclCommandTest.php
+++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SetAclCommandTest.php
@@ -96,7 +96,7 @@ public function testSetAclRole()
$role = 'ROLE_ADMIN';
$application = $this->getApplication();
- $application->add(new SetAclCommand());
+ $application->add(new SetAclCommand($application->getKernel()->getContainer()->get('security.acl.provider')));
$setAclCommand = $application->find('acl:set');
$setAclCommandTester = new CommandTester($setAclCommand);
@@ -138,7 +138,7 @@ public function testSetAclClassScope()
$role = 'ROLE_USER';
$application = $this->getApplication();
- $application->add(new SetAclCommand());
+ $application->add(new SetAclCommand($application->getKernel()->getContainer()->get('security.acl.provider')));
$setAclCommand = $application->find('acl:set');
$setAclCommandTester = new CommandTester($setAclCommand);
@@ -170,7 +170,7 @@ private function getApplication()
$kernel->boot();
$application = new Application($kernel);
- $application->add(new InitAclCommand());
+ $application->add(new InitAclCommand($kernel->getContainer()->get('security.acl.dbal.connection'), $kernel->getContainer()->get('security.acl.dbal.schema')));
$initAclCommand = $application->find('init:acl');
$initAclCommandTester = new CommandTester($initAclCommand);