Skip to content

Commit

Permalink
Remove symfony deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
core23 committed Feb 4, 2024
1 parent 710de21 commit 12a0fba
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 43 deletions.
2 changes: 1 addition & 1 deletion src/Action/UpdateSecurityAction.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;

Expand Down
6 changes: 2 additions & 4 deletions src/Command/ActivateUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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'),
])
Expand Down
6 changes: 2 additions & 4 deletions src/Command/ChangePasswordCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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'),
Expand Down
6 changes: 2 additions & 4 deletions src/Command/CreateUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,17 @@

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\Input\InputOption;
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)
Expand All @@ -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'),
Expand Down
6 changes: 2 additions & 4 deletions src/Command/DeactivateUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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'),
])
Expand Down
6 changes: 2 additions & 4 deletions src/Command/DemoteUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <info>nucleos:user:demote</info> command demotes a user by removing a role
Expand Down
6 changes: 2 additions & 4 deletions src/Command/PromoteUserCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 <info>nucleos:user:promote</info> command promotes a user by adding a role
Expand Down
24 changes: 6 additions & 18 deletions src/Resources/config/commands.php
Original file line number Diff line number Diff line change
Expand Up @@ -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'),
])
Expand Down

0 comments on commit 12a0fba

Please sign in to comment.