8000 feature #23887 [Console] Allow commands to provide a default name for… · symfony/security-bundle@9778a0c · GitHub
[go: up one dir, main page]

Skip to content

Commit 9778a0c

Browse files
committed
feature #23887 [Console] Allow commands to provide a default name for compile time registration (chalasr, nicolas-grekas)
This PR was merged into the 3.4 branch. Discussion ---------- [Console] Allow commands to provide a default name for compile time registration | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | no | New feature? | yes | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | #23796 | License | MIT | Doc PR | symfony/symfony-docs#8147 Commits ------- eda7d42955 [Console] Add protected static $defaultName to set the default name of a Command 5d9ae6b56f [Console] Allow commands to provide a default name for compile time registration
2 parents bf6106e + 8b76405 commit 9778a0c

File tree

5 files changed

+9
-8
lines changed

5 files changed

+9
-8
lines changed

Command/InitAclCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
*/
2828
class InitAclCommand extends ContainerAwareCommand
2929
{
30+
protected static $defaultName = 'init:acl';
31+
3032
private $connection;
3133
private $schema;
3234

@@ -70,7 +72,6 @@ public function isEnabled()
7072
protected function configure()
7173
{
7274
$this
73-
->setName('init:acl')
7475
->setDescription('Mounts ACL tables in the database')
7576
->setHelp(<<<'EOF'
7677
The <info>%command.name%</info> command mounts ACL tables in the database.

Command/SetAclCommand.php

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@
3232
*/
3333
class SetAclCommand extends ContainerAwareCommand
3434
{
35+
protected static $defaultName = 'acl:set';
36+
3537
private $provider;
3638

3739
/**
@@ -80,7 +82,6 @@ public function isEnabled()
8082
protected function configure()
8183
{
8284
$this
83-
->setName('acl:set')
8485
->setDescription('Sets ACL for objects')
8586
->setHelp(<<<EOF
8687
The <info>%command.name%</info> command sets ACL.

Command/UserPasswordEncoderCommand.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@
1919
use Symfony\Component\Console\Output\OutputInterface;
2020
use Symfony\Component\Console\Question\Question;
2121
use Symfony\Component\Console\Style\SymfonyStyle;
22-
use Symfony\Component\DependencyInjection\ContainerAwareInterface;
2322
use Symfony\Component\Security\Core\Encoder\BCryptPasswordEncoder;
2423
use Symfony\Component\Security\Core\Encoder\EncoderFactoryInterface;
2524
use Symfony\Component\Security\Core\User\User;
@@ -33,6 +32,8 @@
3332
*/
3433
class UserPasswordEncoderCommand extends ContainerAwareCommand
3534
{
35+
protected static $defaultName = 'security:encode-password';
36+
3637
private $encoderFactory;
3738
private $userClasses;
3839

@@ -54,7 +55,6 @@ public function __construct(EncoderFactoryInterface $encoderFactory = null, arra
5455
protected function configure()
5556
{
5657
$this
57-
->setName('security:encode-password')
5858
->setDescription('Encodes a password.')
5959
->addArgument('password', InputArgument::OPTIONAL, 'The plain password to encode.')
6060
->addArgument('user-class', InputArgument::OPTIONAL, 'The User entity class path associated with the encoder used to encode the password.')

Tests/Functional/SetAclCommandTest.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@
2020
* file that was distributed with this source code.
2121
*/
2222
use Symfony\Bundle\FrameworkBundle\Console\Application;
23-
use Symfony\Bundle\SecurityBundle\Command\InitAclCommand;
2423
use Symfony\Bundle\SecurityBundle\Command\SetAclCommand;
2524
use Symfony\Component\Console\Tester\CommandTester;
2625
use Symfony\Component\Security\Acl\Domain\ObjectIdentity;
@@ -170,7 +169,6 @@ private function getApplication()
170169
$kernel->boot();
171170

172171
$application = new Application($kernel);
173-
$application->add(new InitAclCommand($kernel->getContainer()->get('security.acl.dbal.connection'), $kernel->getContainer()->get('security.acl.dbal.schema')));
174172

175173
$initAclCommand = $application->find('init:acl');
176174
$initAclCommandTester = new CommandTester($initAclCommand);

composer.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"require-dev": {
2727
"symfony/asset": "~2.8|~3.0|~4.0",
2828
"symfony/browser-kit": "~2.8|~3.0|~4.0",
29-
"symfony/console": "~3.2|~4.0",
29+
"symfony/console": "~3.4|~4.0",
3030
"symfony/css-selector": "~2.8|~3.0|~4.0",
3131
"symfony/dom-crawler": "~2.8|~3.0|~4.0",
3232
"symfony/event-dispatcher": "^3.3.1|~4.0",
@@ -47,7 +47,8 @@
4747
},
4848
"conflict": {
4949
"symfony/var-dumper": "<3.3",
50-
"symfony/event-dispatcher": "<3.3.1"
50+
"symfony/event-dispatcher": "<3.3.1",
51+
"symfony/console": "<3.4"
5152
},
5253
"suggest": {
5354
"symfony/security-acl": "For using the ACL functionality of this bundle"

0 commit comments

Comments
 (0)
0