Skip to content

Commit b52c5fa

Browse files
committed
Internal: Replaced the deprecated protected static $defaultName and setDescription methods with the AsCommand attribute
1 parent 5e462b6 commit b52c5fa

10 files changed

+50
-59
lines changed

src/CoreBundle/Command/LpProgressReminderCommand.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use DateTime;
1717
use DateTimeZone;
1818
use Exception;
19+
use Symfony\Component\Console\Attribute\AsCommand;
1920
use Symfony\Component\Console\Command\Command;
2021
use Symfony\Component\Console\Input\InputInterface;
2122
use Symfony\Component\Console\Input\InputOption;
@@ -24,13 +25,12 @@
2425
use Symfony\Contracts\Translation\TranslatorInterface;
2526
use Twig\Environment;
2627

28+
#[AsCommand(
29+
name: 'app:lp-progress-reminder',
30+
description: 'Send LP progress reminders to users based on "number_of_days_for_completion".',
31+
)]
2732
class LpProgressReminderCommand extends Command
2833
{
29-
/**
30-
* @var string|null
31-
*/
32-
protected static $defaultName = 'app:lp-progress-reminder';
33-
3434
private const NUMBER_OF_DAYS_TO_RESEND_NOTIFICATION = 3;
3535

3636
public function __construct(
@@ -51,7 +51,6 @@ public function __construct(
5151
protected function configure(): void
5252
{
5353
$this
54-
->setDescription('Send LP progress reminders to users based on "number_of_days_for_completion".')
5554
->addOption(
5655
'debug',
5756
null,

src/CoreBundle/Command/ProcessUserDataRequestsCommand.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
use Doctrine\ORM\EntityManager;
1818
use MessageManager;
1919
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
20+
use Symfony\Component\Console\Attribute\AsCommand;
2021
use Symfony\Component\Console\Command\Command;
2122
use Symfony\Component\Console\Input\InputInterface;
2223
use Symfony\Component\Console\Input\InputOption;
@@ -26,13 +27,12 @@
2627
use Symfony\Contracts\Translation\TranslatorInterface;
2728
use UserManager;
2829

30+
#[AsCommand(
31+
name: 'app:process-user-data-requests',
32+
description: 'Process user data requests for personal data actions.',
33+
)]
2934
class ProcessUserDataRequestsCommand extends Command
3035
{
31-
/**
32-
* @var string
33-
*/
34-
protected static $defaultName = 'app:process-user-data-requests';
35-
3636
public function __construct(
3737
private readonly Connection $connection,
3838
private readonly AccessUrlHelper $accessUrlHelper,
@@ -47,7 +47,6 @@ public function __construct(
4747
protected function configure(): void
4848
{
4949
$this
50-
->setDescription('Process user data requests for personal data actions.')
5150
->addOption('debug', null, InputOption::VALUE_NONE, 'Enable debug mode')
5251
->setHelp('This command processes user data requests that require administrative action.')
5352
;

src/CoreBundle/Command/ReinscriptionCheckCommand.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,18 +13,18 @@
1313
use Chamilo\CoreBundle\Repository\SessionRepository;
1414
use DateTime;
1515
use Doctrine\ORM\EntityManagerInterface;
16+
use Symfony\Component\Console\Attribute\AsCommand;
1617
use Symfony\Component\Console\Command\Command;
1718
use Symfony\Component\Console\Input\InputInterface;
1819
use Symfony\Component\Console\Input\InputOption;
1920
use Symfony\Component\Console\Output\OutputInterface;
2021

22+
#[AsCommand(
23+
name: 'app:reinscription-check',
24+
description: 'Checks for users who have validated all gradebooks and reinscribe them into new sessions if needed.',
25+
)]
2126
class ReinscriptionCheckCommand extends Command
2227
{
23-
/**
24-
* @var string
25-
*/
26-
protected static $defaultName = 'app:reinscription-check';
27-
2828
private SessionRepository $sessionRepository;
2929
private GradebookCertificateRepository $certificateRepository;
3030
private EntityManagerInterface $entityManager;
@@ -43,7 +43,6 @@ public function __construct(
4343
protected function configure(): void
4444
{
4545
$this
46-
->setDescription('Checks for users who have validated all gradebooks and reinscribe them into new sessions if needed.')
4746
->addOption(
4847
'debug',
4948
null,

src/CoreBundle/Command/SendCourseExpirationEmailsCommand.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use DateTime;
1313
use DateTimeZone;
1414
use Doctrine\ORM\EntityManagerInterface;
15+
use Symfony\Component\Console\Attribute\AsCommand;
1516
use Symfony\Component\Console\Command\Command;
1617
use Symfony\Component\Console\Input\InputInterface;
1718
use Symfony\Component\Console\Input\InputOption;
@@ -22,13 +23,12 @@
2223
use Twig\Environment;
2324
use UserManager;
2425

26+
#[AsCommand(
27+
name: 'app:send-course-expiration-emails',
28+
description: 'Send an email to users when their course is finished.',
29+
)]
2530
class SendCourseExpirationEmailsCommand extends Command
2631
{
27-
/**
28-
* @var string
29-
*/
30-
protected static $defaultName = 'app:send-course-expiration-emails';
31-
3232
public function __construct(
3333
private readonly EntityManagerInterface $entityManager,
3434
private readonly SettingsManager $settingsManager,
@@ -41,7 +41,6 @@ public function __construct(
4141
protected function configure(): void
4242
{
4343
$this
44-
->setDescription('Send an email to users when their course is finished.')
4544
->addOption('debug', null, InputOption::VALUE_NONE, 'Enable debug mode')
4645
->setHelp('This command sends an email to users whose course session is expiring today.')
4746
;

src/CoreBundle/Command/SendCourseExpirationRemindersCommand.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
use DateTimeZone;
1313
use Doctrine\DBAL\Connection;
1414
use Symfony\Bridge\Twig\Mime\TemplatedEmail;
15+
use Symfony\Component\Console\Attribute\AsCommand;
1516
use Symfony\Component\Console\Command\Command;
1617
use Symfony\Component\Console\Input\InputInterface;
1718
use Symfony\Component\Console\Input\InputOption;
@@ -20,13 +21,12 @@
2021
use Symfony\Component\Mailer\Exception\TransportExceptionInterface;
2122
use Symfony\Component\Mailer\MailerInterface;
2223

24+
#[AsCommand(
25+
name: 'app:send-course-expiration-reminders',
26+
description: 'Send course expiration reminders to users.',
27+
)]
2328
class SendCourseExpirationRemindersCommand extends Command
2429
{
25-
/**
26-
* @var string
27-
*/
28-
protected static $defaultName = 'app:send-course-expiration-reminders';
29-
3030
public function __construct(
3131
private readonly Connection $connection,
3232
private readonly MailerInterface $mailer,
@@ -38,7 +38,6 @@ public function __construct(
3838
protected function configure(): void
3939
{
4040
$this
41-
->setDescription('Send course expiration reminders to users.')
4241
->addOption('debug', null, InputOption::VALUE_NONE, 'Enable debug mode')
4342
->setHelp('This command sends email reminders to users before their course access expires.')
4443
;

src/CoreBundle/Command/SendEventRemindersCommand.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
use DateTime;
1717
use DateTimeZone;
1818
use Doctrine\ORM\EntityManagerInterface;
19+
use Symfony\Component\Console\Attribute\AsCommand;
1920
use Symfony\Component\Console\Command\Command;
2021
use Symfony\Component\Console\Input\InputInterface;
2122
use Symfony\Component\Console\Input\InputOption;
@@ -25,13 +26,12 @@
2526

2627
use const PHP_EOL;
2728

29+
#[AsCommand(
30+
name: 'app:send-event-reminders',
31+
description: 'Send notification messages to users that have reminders from events in their agenda.',
32+
)]
2833
class SendEventRemindersCommand extends Command
2934
{
30-
/**
31-
* @var string
32-
*/
33-
protected static $defaultName = 'app:send-event-reminders';
34-
3535
public function __construct(
3636
private readonly EntityManagerInterface $entityManager,
3737
private readonly SettingsManager $settingsManager,
@@ -45,7 +45,6 @@ public function __construct(
4545
protected function configure(): void
4646
{
4747
$this
48-
->setDescription('Send notification messages to users that have reminders from events in their agenda.')
4948
->addOption('debug', null, InputOption::VALUE_NONE, 'Enable debug mode')
5049
->setHelp('This command sends notifications to users who have pending reminders for calendar events.')
5150
;

src/CoreBundle/Command/SendNotificationsCommand.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,19 +10,19 @@
1010
use Database;
1111
use Doctrine\ORM\EntityManager;
1212
use Notification;
13+
use Symfony\Component\Console\Attribute\AsCommand;
1314
use Symfony\Component\Console\Command\Command;
1415
use Symfony\Component\Console\Input\InputInterface;
1516
use Symfony\Component\Console\Input\InputOption;
1617
use Symfony\Component\Console\Output\OutputInterface;
1718
use Symfony\Component\Console\Style\SymfonyStyle;
1819

20+
#[AsCommand(
21+
name: 'app:send-notifications',
22+
description: 'Send notifications',
23+
)]
1924
class SendNotificationsCommand extends Command
2025
{
21-
/**
22-
* @var string
23-
*/
24-
protected static $defaultName = 'app:send-notifications';
25-
2626
public function __construct(
2727
private readonly EntityManager $em
2828
) {
@@ -32,7 +32,6 @@ public function __construct(
3232
protected function configure(): void
3333
{
3434
$this
35-
->setDescription('Send notifications')
3635
->addOption('debug', null, InputOption::VALUE_NONE, 'Enable debug mode')
3736
->setHelp('This command sends notifications using the Notification class.')
3837
;

src/CoreBundle/Command/SendScheduledAnnouncementsCommand.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,19 @@
1212
use Database;
1313
use Doctrine\ORM\EntityManager;
1414
use Exception;
15+
use Symfony\Component\Console\Attribute\AsCommand;
1516
use Symfony\Component\Console\Command\Command;
1617
use Symfony\Component\Console\Input\InputInterface;
1718
use Symfony\Component\Console\Input\InputOption;
1819
use Symfony\Component\Console\Output\OutputInterface;
1920
use Symfony\Component\Console\Style\SymfonyStyle;
2021

22+
#[AsCommand(
23+
name: 'app:send-scheduled-announcements',
24+
description: 'Send scheduled announcements to all users.',
25+
)]
2126
class SendScheduledAnnouncementsCommand extends Command
2227
{
23-
/**
24-
* @var string
25-
*/
26-
protected static $defaultName = 'app:send-scheduled-announcements';
27-
2828
public function __construct(
2929
private readonly AccessUrlRepository $accessUrlRepository,
3030
private readonly ScheduledAnnouncementService $scheduledAnnouncementService,
@@ -36,7 +36,6 @@ public function __construct(
3636
protected function configure(): void
3737
{
3838
$this
39-
->setDescription('Send scheduled announcements to all users.')
4039
->addOption('debug', null, InputOption::VALUE_NONE, 'If set, debug messages will be shown.')
4140
;
4241
}

src/CoreBundle/Command/SessionRepetitionCommand.php

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,19 @@
1515
use Chamilo\CoreBundle\ServiceHelper\MessageHelper;
1616
use Doctrine\ORM\EntityManagerInterface;
1717
use Exception;
18+
use Symfony\Component\Console\Attribute\AsCommand;
1819
use Symfony\Component\Console\Command\Command;
1920
use Symfony\Component\Console\Input\InputInterface;
2021
use Symfony\Component\Console\Input\InputOption;
2122
use Symfony\Component\Console\Output\OutputInterface;
2223
use Symfony\Contracts\Translation\TranslatorInterface;
2324

25+
#[AsCommand(
26+
name: 'app:session-repetition',
27+
description: 'Automatically duplicates sessions that meet the repetition criteria.',
28+
)]
2429
class SessionRepetitionCommand extends Command
2530
{
26-
/**
27-
* @var string
28-
*/
29-
protected static $defaultName = 'app:session-repetition';
3031
private string $baseUrl;
3132

3233
public function __construct(
@@ -41,7 +42,6 @@ public function __construct(
4142
protected function configure(): void
4243
{
4344
$this
44-
->setDescription('Automatically duplicates sessions that meet the repetition criteria.')
4545
->addOption('debug', null, InputOption::VALUE_NONE, 'Enable debug mode')
4646
->addOption('base-url', null, InputOption::VALUE_REQUIRED, 'Base URL for generating session links')
4747
;

src/CoreBundle/Command/UpdateSessionStatusCommand.php

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use DateTime;
1212
use DateTimeZone;
1313
use Doctrine\ORM\EntityManagerInterface;
14+
use Symfony\Component\Console\Attribute\AsCommand;
1415
use Symfony\Component\Console\Command\Command;
1516
use Symfony\Component\Console\Input\InputInterface;
1617
use Symfony\Component\Console\Input\InputOption;
@@ -20,13 +21,12 @@
2021
use const PHP_EOL;
2122
use const PHP_SAPI;
2223

24+
#[AsCommand(
25+
name: 'app:update-session-status',
26+
description: 'Updates the status of training sessions based on their dates and user count.',
27+
)]
2328
class UpdateSessionStatusCommand extends Command
2429
{
25-
/**
26-
* @var string
27-
*/
28-
protected static $defaultName = 'app:update-session-status';
29-
3030
public function __construct(
3131
private readonly EntityManagerInterface $entityManager,
3232
private readonly SessionRepository $sessionRepository
@@ -37,7 +37,6 @@ public function __construct(
3737
protected function configure(): void
3838
{
3939
$this
40-
->setDescription('Updates the status of training sessions based on their dates and user count.')
4140
->addOption('debug', null, InputOption::VALUE_NONE, 'Enable debug mode')
4241
;
4342
}

0 commit comments

Comments
 (0)