diff --git a/src/Symfony/Bridge/Twig/Command/DebugCommand.php b/src/Symfony/Bridge/Twig/Command/DebugCommand.php index e9519adb66..0c68c637f8 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 2aae6120d3..f96da4d615 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 b8ad74300d..ffc770c7a5 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 631b31b600..c3a7bf450e 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 60c42e8729..fec933f67b 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 0f72db8305..57972782dc 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 d2f8bd7775..18aa08575c 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 253f9a13f2..2a00509032 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 c6d2bdbf99..f88d2a2dfe 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 44730737bc..f8e69a3c4a 100644 --- a/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php +++ b/src/Symfony/Bundle/FrameworkBundle/Command/TranslationDebugCommand.php @@ -36,14 +36,14 @@ use Symfony\Component\Translation\TranslatorInterface; */ 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 a02cb23a57..357902a209 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 8f4739a9f8..36876dee24 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 @@ use Symfony\Component\Translation\Command\XliffLintCommand as BaseLintCommand; * * @final since version 3.4 */ -class XliffLintCommand extends Command +class XliffLintCommand extends BaseLintCommand { - private $command; + public function __construct($name = null, $directoryIteratorProvider = null, $isReadableProvider = null) + { + 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); + } + + if (null === $directoryIteratorProvider) { + $directoryIteratorProvider = function ($directory, $default) { + if (!is_dir($directory)) { + $directory = $this->getApplication()->getKernel()->locateResource($directory); + } + + return $default($directory); + }; + } + + if (null === $isReadableProvider) { + $isReadableProvider = function ($fileOrDirectory, $default) { + return 0 === strpos($fileOrDirectory, '@') || $default($fileOrDirectory); + }; + } + + parent::__construct($name, $directoryIteratorProvider, $isReadableProvider); + } /** * {@inheritdoc} */ protected function configure() { - $this->setName('lint:xliff'); + parent::configure(); - if (!$this->isEnabled()) { - return; - } - - $directoryIteratorProvider = function ($directory, $default) { - if (!is_dir($directory)) { - $directory = $this->getApplication()->getKernel()->locateResource($directory); - } - - return $default($directory); - }; - - $isReadableProvider = function ($fileOrDirectory, $default) { - return 0 === strpos($fileOrDirectory, '@') || $default($fileOrDirectory); - }; - - $this->command = new BaseLintCommand(null, $directoryIteratorProvider, $isReadableProvider); - - $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 @@ Or find all files in a bundle: 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 6e8f7dbfae..f6c1a7f85b 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 @@ use Symfony\Component\Yaml\Command\LintCommand as BaseLintCommand; * * @final since version 3.4 */ -class YamlLintCommand extends Command +class YamlLintCommand extends BaseLintCommand { - private $command; + public function __construct($name = null, $directoryIteratorProvider = null, $isReadableProvider = null) + { + 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); + } + + if (null === $directoryIteratorProvider) { + $directoryIteratorProvider = function ($directory, $default) { + if (!is_dir($directory)) { + $directory = $this->getApplication()->getKernel()->locateResource($directory); + } + + return $default($directory); + }; + } + + if (null === $isReadableProvider) { + $isReadableProvider = function ($fileOrDirectory, $default) { + return 0 === strpos($fileOrDirectory, '@') || $default($fileOrDirectory); + }; + } + + parent::__construct($name, $directoryIteratorProvider, $isReadableProvider); + } /** * {@inheritdoc} */ protected function configure() { - $this->setName('lint:yaml'); + parent::configure(); - if (!$this->isEnabled()) { - return; - } - - $directoryIteratorProvider = function ($directory, $default) { - if (!is_dir($directory)) { - $directory = $this->getApplication()->getKernel()->locateResource($directory); - } - - return $default($directory); - }; - - $isReadableProvider = function ($fileOrDirectory, $default) { - return 0 === strpos($fileOrDirectory, '@') || $default($fileOrDirectory); - }; - - $this->command = new BaseLintCommand(null, $directoryIteratorProvider, $isReadableProvider); - - $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 @@ Or find all files in a bundle: 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 a3aad4bcd3..38b4c62784 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\RouterMatchCommand; 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\DenormalizerInterface; 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 @@ class FrameworkExtension extends Extension 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 1512e910c9..597df8ceb9 100644 --- a/src/Symfony/Bundle/SecurityBundle/Command/InitAclCommand.php +++ b/src/Symfony/Bundle/SecurityBundle/Command/InitAclCommand.php @@ -14,6 +14,8 @@ namespace Symfony\Bundle\SecurityBundle\Command; 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 @@ use Doctrine\DBAL\Schema\SchemaException; */ 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 @@ EOF */ 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 7d0146fdc6..840e74edfb 100644 --- a/src/Symfony/Bundle/SecurityBundle/Command/SetAclCommand.php +++ b/src/Symfony/Bundle/SecurityBundle/Command/SetAclCommand.php @@ -32,11 +32,36 @@ use Symfony\Component\Security\Acl\Model\MutableAclProviderInterface; */ 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 @@ EOF */ 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 @@ EOF } } - /** @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 @@ EOF } } - $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 4a77c13b48..dffe9d3687 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 @@ class SecurityExtension extends Extension // 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 f14b4a5a35..b375d95eff 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 3b060a86fc..1ceaca1002 100644 --- a/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SetAclCommandTest.php +++ b/src/Symfony/Bundle/SecurityBundle/Tests/Functional/SetAclCommandTest.php @@ -96,7 +96,7 @@ class SetAclCommandTest extends WebTestCase $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 @@ class SetAclCommandTest extends WebTestCase $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 @@ class SetAclCommandTest extends WebTestCase $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);