diff --git a/src/Action/UpdateSecurityAction.php b/src/Action/UpdateSecurityAction.php
index c270a093..8b507a80 100644
--- a/src/Action/UpdateSecurityAction.php
+++ b/src/Action/UpdateSecurityAction.php
@@ -21,6 +21,7 @@
use Nucleos\UserBundle\Model\UserManager;
use Nucleos\UserBundle\NucleosUserEvents;
use Nucleos\UserBundle\Util\UserManipulator;
+use Symfony\Bundle\SecurityBundle\Security;
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
use Symfony\Component\Form\FormFactoryInterface;
use Symfony\Component\Form\FormInterface;
@@ -29,7 +30,6 @@
use Symfony\Component\HttpFoundation\Response;
use Symfony\Component\Routing\RouterInterface;
use Symfony\Component\Security\Core\Exception\AccessDeniedException;
-use Symfony\Component\Security\Core\Security;
use Symfony\Contracts\EventDispatcher\EventDispatcherInterface;
use Twig\Environment;
diff --git a/src/Command/ActivateUserCommand.php b/src/Command/ActivateUserCommand.php
index 00212762..dd8d7457 100644
--- a/src/Command/ActivateUserCommand.php
+++ b/src/Command/ActivateUserCommand.php
@@ -15,16 +15,16 @@
use Nucleos\UserBundle\Util\UserManipulator;
use RuntimeException;
+use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;
+#[AsCommand(name: 'nucleos:user:activate', description: 'Activate a user')]
final class ActivateUserCommand extends Command
{
- protected static $defaultName = 'nucleos:user:activate';
-
private readonly UserManipulator $userManipulator;
public function __construct(UserManipulator $userManipulator)
@@ -37,8 +37,6 @@ public function __construct(UserManipulator $userManipulator)
protected function configure(): void
{
$this
- ->setName('nucleos:user:activate')
- ->setDescription('Activate a user')
->setDefinition([
new InputArgument('username', InputArgument::REQUIRED, 'The username'),
])
diff --git a/src/Command/ChangePasswordCommand.php b/src/Command/ChangePasswordCommand.php
index b61e2193..f8d5b5ac 100644
--- a/src/Command/ChangePasswordCommand.php
+++ b/src/Command/ChangePasswordCommand.php
@@ -15,16 +15,16 @@
use Nucleos\UserBundle\Util\UserManipulator;
use RuntimeException;
+use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;
+#[AsCommand(name: 'nucleos:user:change-password', description: 'Change the password of a user.')]
final class ChangePasswordCommand extends Command
{
- protected static $defaultName = 'nucleos:user:change-password';
-
private readonly UserManipulator $userManipulator;
public function __construct(UserManipulator $userManipulator)
@@ -37,8 +37,6 @@ public function __construct(UserManipulator $userManipulator)
protected function configure(): void
{
$this
- ->setName('nucleos:user:change-password')
- ->setDescription('Change the password of a user.')
->setDefinition([
new InputArgument('username', InputArgument::REQUIRED, 'The username'),
new InputArgument('password', InputArgument::REQUIRED, 'The password'),
diff --git a/src/Command/CreateUserCommand.php b/src/Command/CreateUserCommand.php
index 532f9243..b23ca98c 100644
--- a/src/Command/CreateUserCommand.php
+++ b/src/Command/CreateUserCommand.php
@@ -15,6 +15,7 @@
use Nucleos\UserBundle\Util\UserManipulator;
use RuntimeException;
+use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
@@ -22,10 +23,9 @@
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;
+#[AsCommand(name: 'nucleos:user:create', description: 'Create a user.')]
final class CreateUserCommand extends Command
{
- protected static $defaultName = 'nucleos:user:create';
-
private readonly UserManipulator $userManipulator;
public function __construct(UserManipulator $userManipulator)
@@ -38,8 +38,6 @@ public function __construct(UserManipulator $userManipulator)
protected function configure(): void
{
$this
- ->setName('nucleos:user:create')
- ->setDescription('Create a user.')
->setDefinition([
new InputArgument('username', InputArgument::REQUIRED, 'The username'),
new InputArgument('email', InputArgument::REQUIRED, 'The email'),
diff --git a/src/Command/DeactivateUserCommand.php b/src/Command/DeactivateUserCommand.php
index b05aca6f..9a2bb961 100644
--- a/src/Command/DeactivateUserCommand.php
+++ b/src/Command/DeactivateUserCommand.php
@@ -15,16 +15,16 @@
use Nucleos\UserBundle\Util\UserManipulator;
use RuntimeException;
+use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Question\Question;
+#[AsCommand(name: 'nucleos:user:deactivate', description: 'Deactivate a user')]
final class DeactivateUserCommand extends Command
{
- protected static $defaultName = 'nucleos:user:deactivate';
-
private readonly UserManipulator $userManipulator;
public function __construct(UserManipulator $userManipulator)
@@ -37,8 +37,6 @@ public function __construct(UserManipulator $userManipulator)
protected function configure(): void
{
$this
- ->setName('nucleos:user:deactivate')
- ->setDescription('Deactivate a user')
->setDefinition([
new InputArgument('username', InputArgument::REQUIRED, 'The username'),
])
diff --git a/src/Command/DemoteUserCommand.php b/src/Command/DemoteUserCommand.php
index d020ad3f..3d870e64 100644
--- a/src/Command/DemoteUserCommand.php
+++ b/src/Command/DemoteUserCommand.php
@@ -14,19 +14,17 @@
namespace Nucleos\UserBundle\Command;
use Nucleos\UserBundle\Util\UserManipulator;
+use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Output\OutputInterface;
+#[AsCommand(name: 'nucleos:user:demote', description: 'Demote a user by removing a role')]
final class DemoteUserCommand extends RoleCommand
{
- protected static $defaultName = 'nucleos:user:demote';
-
protected function configure(): void
{
parent::configure();
$this
- ->setName('nucleos:user:demote')
- ->setDescription('Demote a user by removing a role')
->setHelp(
<<<'EOT'
The nucleos:user:demote command demotes a user by removing a role
diff --git a/src/Command/PromoteUserCommand.php b/src/Command/PromoteUserCommand.php
index 6e5613d1..abe3a4d6 100644
--- a/src/Command/PromoteUserCommand.php
+++ b/src/Command/PromoteUserCommand.php
@@ -14,19 +14,17 @@
namespace Nucleos\UserBundle\Command;
use Nucleos\UserBundle\Util\UserManipulator;
+use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Output\OutputInterface;
+#[AsCommand(name: 'nucleos:user:promote', description: 'Promotes a user by adding a role')]
final class PromoteUserCommand extends RoleCommand
{
- protected static $defaultName = 'nucleos:user:promote';
-
protected function configure(): void
{
parent::configure();
$this
- ->setName('nucleos:user:promote')
- ->setDescription('Promotes a user by adding a role')
->setHelp(
<<<'EOT'
The nucleos:user:promote command promotes a user by adding a role
diff --git a/src/Resources/config/commands.php b/src/Resources/config/commands.php
index d6b96cf4..a80b4da2 100644
--- a/src/Resources/config/commands.php
+++ b/src/Resources/config/commands.php
@@ -23,49 +23,37 @@
$container->services()
->set(ActivateUserCommand::class)
- ->tag('console.command', [
- 'command' => 'nucleos:user:activate',
- ])
+ ->tag('console.command')
->args([
new Reference('nucleos_user.util.user_manipulator'),
])
->set(ChangePasswordCommand::class)
- ->tag('console.command', [
- 'command' => 'nucleos:user:change-password',
- ])
+ ->tag('console.command')
->args([
new Reference('nucleos_user.util.user_manipulator'),
])
->set(CreateUserCommand::class)
- ->tag('console.command', [
- 'command' => 'nucleos:user:create',
- ])
+ ->tag('console.command')
->args([
new Reference('nucleos_user.util.user_manipulator'),
])
->set(DeactivateUserCommand::class)
- ->tag('console.command', [
- 'command' => 'nucleos:user:deactivate',
- ])
+ ->tag('console.command')
->args([
new Reference('nucleos_user.util.user_manipulator'),
])
->set(DemoteUserCommand::class)
- ->tag('console.command', [
- 'command' => 'nucleos:user:demote',
- ])
+ ->tag('console.command')
->args([
new Reference('nucleos_user.util.user_manipulator'),
])
->set(PromoteUserCommand::class)
- ->tag('console.command', [
- 'command' => 'nucleos:user:promote',
- ])
+ ->tag('console.command')
->args([
new Reference('nucleos_user.util.user_manipulator'),
])