Skip to content

Commit

Permalink
Suppression des dépréciations pour les Command (#1639)
Browse files Browse the repository at this point in the history
  • Loading branch information
stakovicz authored Feb 19, 2025
1 parent 737d741 commit 47b509a
Show file tree
Hide file tree
Showing 21 changed files with 206 additions and 196 deletions.
23 changes: 11 additions & 12 deletions app/config/services.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,17 @@ services:
lock_mode: !php/const Symfony\Component\HttpFoundation\Session\Storage\Handler\PdoSessionHandler::LOCK_NONE


AppBundle\Command\:
resource: '../../sources/AppBundle/Command/*'
autowire: true
autoconfigure: true

AppBundle\Command\UpdateMailchimpMembersCommand:
arguments:
- '@Mailchimp\Mailchimp'
- '@CCMBenchmark\TingBundle\Repository\RepositoryFactory'
- "%mailchimp_members_list%"

AppBundle\Controller\:
resource: '../../sources/AppBundle/Controller/*'
autowire: true
Expand Down Expand Up @@ -125,18 +136,6 @@ services:
arguments:
$backOfficePages: '%app.pages_backoffice%'

AppBundle\Command\GeneralMeetupNotificationCommand:
autowire: true
autoconfigure: true

AppBundle\Command\IndexTalksCommand:
autowire: true
autoconfigure: true

AppBundle\Command\QrCodesGeneratorCommand:
autowire: true
autoconfigure: true

AppBundle\GeneralMeeting\GeneralMeetingRepository:
autowire: true

Expand Down
16 changes: 5 additions & 11 deletions sources/AppBundle/Command/CfpNotificationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,12 @@
use AppBundle\Notifier\SlackNotifier;
use AppBundle\Slack\MessageFactory;
use CCMBenchmark\TingBundle\Repository\RepositoryFactory;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class CfpNotificationCommand extends ContainerAwareCommand
class CfpNotificationCommand extends Command
{
private MessageFactory $messageFactory;
private SlackNotifier $slackNotifier;
Expand All @@ -29,22 +29,16 @@ public function __construct(MessageFactory $messageFactory,
$this->messageFactory = $messageFactory;
$this->slackNotifier = $slackNotifier;
$this->ting = $ting;
parent::__construct();
}
/**
* @see Command
*/

protected function configure(): void
{
$this
->setName('cfp-stats-notification')
->addOption('display-diff', null, InputOption::VALUE_NONE)

;
->addOption('display-diff', null, InputOption::VALUE_NONE);
}

/**
* @see Command
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$eventRepository = $this->ting->get(EventRepository::class);
Expand Down
16 changes: 6 additions & 10 deletions sources/AppBundle/Command/CleanThrottlingCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,30 +5,26 @@
namespace AppBundle\Command;

use AppBundle\Security\ActionThrottling\ActionThrottling;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class CleanThrottlingCommand extends ContainerAwareCommand
class CleanThrottlingCommand extends Command
{
private ActionThrottling $actionThrottling;

public function __construct(ActionThrottling $actionThrottling)
{
$this->actionThrottling = $actionThrottling;
parent::__construct();
}
/**
* @see Command
*/

protected function configure(): void
{
$this
->setName('throttling:clean')
;
->setName('throttling:clean');
}

/**
* @see Command
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$this->actionThrottling->clearOldLogs();
Expand Down
16 changes: 5 additions & 11 deletions sources/AppBundle/Command/DevCallBackPayboxCotisationCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,13 @@
namespace AppBundle\Command;

use function GuzzleHttp\Psr7\parse_query;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class DevCallBackPayboxCotisationCommand extends ContainerAwareCommand
class DevCallBackPayboxCotisationCommand extends Command
{
/**
* @see Command
*/
protected function configure(): void
{
$help = <<<EOF
Expand All @@ -24,14 +22,10 @@ protected function configure(): void

$this
->setName('dev:callback-paybox-cotisation')
->addArgument('url_paiement_effectue')
->setHelp($help)
;
->addArgument('url_paiement_effectue', InputArgument::REQUIRED)
->setHelp($help);
}

/**
* @see Command
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$parsedUrl = parse_url($input->getArgument('url_paiement_effectue'));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,17 +36,11 @@ public function __construct(
$this->urlGenerator = $urlGenerator;
}

/**
* @see Command
*/
protected function configure(): void
{
$this->setName('general-meeting-notification');
}

/**
* @see Command
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
if ($this->generalMeetingRepository->hasGeneralMeetingPlanned()) {
Expand Down
28 changes: 16 additions & 12 deletions sources/AppBundle/Command/IndexMeetupsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,25 @@
use Algolia\AlgoliaSearch\SearchClient;
use AppBundle\Event\Model\Repository\MeetupRepository;
use AppBundle\Indexation\Meetups\Runner;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use CCMBenchmark\TingBundle\Repository\RepositoryFactory;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\ArrayInput;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class IndexMeetupsCommand extends ContainerAwareCommand
class IndexMeetupsCommand extends Command
{
/**
* @see Command
*/
private RepositoryFactory $ting;
private SearchClient $searchClient;

public function __construct(RepositoryFactory $ting,
SearchClient $searchClient)
{
$this->ting = $ting;
$this->searchClient = $searchClient;
parent::__construct();
}

protected function configure(): void
{
$this
Expand All @@ -32,18 +41,13 @@ protected function configure(): void
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$container = $this->getContainer();
$ting = $this->getContainer()->get('ting');

/** @var SearchClient $algoliaClient */
$algoliaClient = $container->get(SearchClient::class);
$meetupRepository = $ting->get(MeetupRepository::class);
$meetupRepository = $this->ting->get(MeetupRepository::class);

if ($input->getOption('run-scraping')) {
$this->runScraping($output);
}

$runner = new Runner($algoliaClient, $meetupRepository);
$runner = new Runner($this->searchClient, $meetupRepository);
$runner->run();

return 0;
Expand Down
2 changes: 1 addition & 1 deletion sources/AppBundle/Command/IndexTalksCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ class IndexTalksCommand extends Command

public function __construct(Runner $runner)
{
parent::__construct(null);
parent::__construct();
$this->runner = $runner;
}

Expand Down
16 changes: 8 additions & 8 deletions sources/AppBundle/Command/QrCodesGeneratorCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,26 @@

use AppBundle\Event\Model\Repository\TicketRepository;
use AppBundle\Event\Ticket\QrCodeGenerator;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use CCMBenchmark\TingBundle\Repository\RepositoryFactory;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

class QrCodesGeneratorCommand extends ContainerAwareCommand
class QrCodesGeneratorCommand extends Command
{
private QrCodeGenerator $qrCodeGenerator;
private RepositoryFactory $ting;

public function __construct(QrCodeGenerator $qrCodeGenerator, string $name = null)
public function __construct(QrCodeGenerator $qrCodeGenerator,
RepositoryFactory $ting)
{
parent::__construct($name);
parent::__construct();
$this->qrCodeGenerator = $qrCodeGenerator;
$this->ting = $ting;
}

/**
* @see Command
*/
protected function configure(): void
{
$this
Expand All @@ -50,7 +50,7 @@ protected function execute(InputInterface $input, OutputInterface $output): int

try {
/** @var TicketRepository $ticketRepository */
$ticketRepository = $this->getContainer()->get('ting')->get(TicketRepository::class);
$ticketRepository = $this->ting->get(TicketRepository::class);
$tickets = $ticketRepository->getByEmptyQrCodes();

if (count($tickets) === 0) {
Expand Down
27 changes: 15 additions & 12 deletions sources/AppBundle/Command/RegistrationsExporterCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,24 @@

use AppBundle\Event\Model\Repository\EventRepository;
use AppBundle\Event\Ticket\RegistrationsExportGenerator;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;

class RegistrationsExporterCommand extends ContainerAwareCommand
class RegistrationsExporterCommand extends Command
{
/**
* @see Command
*/
private EventRepository $eventRepository;
private RegistrationsExportGenerator $exportGenerator;

public function __construct(EventRepository $eventRepository,
RegistrationsExportGenerator $exportGenerator)
{
parent::__construct();
$this->eventRepository = $eventRepository;
$this->exportGenerator = $exportGenerator;
}

protected function configure(): void
{
$this
Expand All @@ -24,21 +32,16 @@ protected function configure(): void
;
}

/**
* @see Command
*/
protected function execute(InputInterface $input, OutputInterface $output): int
{
$container = $this->getContainer();

if (null === ($event = $container->get(EventRepository::class)->getNextEvent())) {
if (null === ($event = $this->eventRepository->getNextEvent())) {
$output->writeln('No event found');
return 0;
}

$file = new \SplFileObject($input->getArgument('file'), 'w+');

$container->get(RegistrationsExportGenerator::class)->export($event, $file);
$this->exportGenerator->export($event, $file);

return 0;
}
Expand Down
24 changes: 16 additions & 8 deletions sources/AppBundle/Command/ScrappingMeetupEventsCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,28 @@

use AppBundle\Event\Model\Repository\MeetupRepository;
use AppBundle\Indexation\Meetups\MeetupClient;
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
use CCMBenchmark\TingBundle\Repository\RepositoryFactory;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Command\LockableTrait;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;

class ScrappingMeetupEventsCommand extends ContainerAwareCommand
class ScrappingMeetupEventsCommand extends Command
{
use LockableTrait;

private RepositoryFactory $ting;
private MeetupClient $meetupClient;

public function __construct(RepositoryFactory $ting,
MeetupClient $meetupClient)
{
parent::__construct();
$this->ting = $ting;
$this->meetupClient = $meetupClient;
}

protected function configure(): void
{
$this
Expand All @@ -37,13 +49,9 @@ protected function execute(InputInterface $input, OutputInterface $output): int
}

try {
$ting = $this->getContainer()->get('ting');

/** @var MeetupClient $meetupClient */
$meetupClient = $this->getContainer()->get(MeetupClient::class);
$meetups = $meetupClient->getEvents();
$meetups = $this->meetupClient->getEvents();

$meetupRepository = $ting->get(MeetupRepository::class);
$meetupRepository = $this->ting->get(MeetupRepository::class);

$io->progressStart(count($meetups));
foreach ($meetups as $meetup) {
Expand Down
Loading

0 comments on commit 47b509a

Please sign in to comment.