Skip to content

Commit

Permalink
fix deprecation warnings on Command
Browse files Browse the repository at this point in the history
  • Loading branch information
mmucklo committed Dec 31, 2019
1 parent 513fea9 commit 4ff604f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 17 deletions.
8 changes: 5 additions & 3 deletions Command/CountCommand.php
Expand Up @@ -2,11 +2,11 @@

namespace Dtc\QueueBundle\Command;

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 CountCommand extends ContainerAwareCommand
class CountCommand extends Command
{
protected function configure()
{
Expand All @@ -17,7 +17,8 @@ protected function configure()

protected function execute(InputInterface $input, OutputInterface $output)
{
$container = $this->getContainer();
// @TODO: move this to dependency injection.
$container = $this->getApplication()->getKernel()->getContainer();
$jobManager = $container->get('dtc_queue.manager.job');

$waitingCount = $jobManager->getWaitingJobCount();
Expand All @@ -41,6 +42,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

$output->writeln("Total waiting jobs: {$waitingCount}");
return 0;
}

/**
Expand Down
8 changes: 5 additions & 3 deletions Command/CreateJobCommand.php
Expand Up @@ -3,13 +3,13 @@
namespace Dtc\QueueBundle\Command;

use Dtc\QueueBundle\Exception\WorkerNotRegisteredException;
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\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class CreateJobCommand extends ContainerAwareCommand
class CreateJobCommand extends Command
{
protected static $defaultName = 'dtc:queue:create_job';

Expand Down Expand Up @@ -85,7 +85,8 @@ private function getHelpMessage()

protected function execute(InputInterface $input, OutputInterface $output)
{
$container = $this->getContainer();
// @TODO: move this to dependency injection.
$container = $this->getApplication()->getKernel()->getContainer();
$jobManager = $container->get('dtc_queue.manager.job');
$workerManager = $container->get('dtc_queue.manager.worker');

Expand All @@ -110,6 +111,7 @@ protected function execute(InputInterface $input, OutputInterface $output)
$job->setArgs($args);

$jobManager->save($job);
return 0;
}

protected function getArgs(InputInterface $input)
Expand Down
13 changes: 8 additions & 5 deletions Command/PruneCommand.php
Expand Up @@ -4,13 +4,13 @@

use Dtc\QueueBundle\Exception\UnsupportedException;
use Dtc\QueueBundle\Util\Util;
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\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;

class PruneCommand extends ContainerAwareCommand
class PruneCommand extends Command
{
const OLDER_MESSAGE = '<int>[d|m|y|h|i|s] Specify how old the jobs should (defaults to timestamp unless a quantifier is specified [d_ays, m_onths, y_years, h_ours, i_minutes, s_econds';

Expand Down Expand Up @@ -49,15 +49,17 @@ protected function execute(InputInterface $input, OutputInterface $output)

protected function pruneExceptionJobs(OutputInterface $output)
{
$container = $this->getContainer();
// @TODO: move this to dependency injection.
$container = $this->getApplication()->getKernel()->getContainer();
$jobManager = $container->get('dtc_queue.manager.job');
$count = $jobManager->pruneExceptionJobs();
$output->writeln("$count Job(s) with status 'exception' pruned");
}

public function executeStalledOther(InputInterface $input, OutputInterface $output)
{
$container = $this->getContainer();
// @TODO: move this to dependency injection.
$container = $this->getApplication()->getKernel()->getContainer();
$jobManager = $container->get('dtc_queue.manager.job');
$type = $input->getArgument('type');
switch ($type) {
Expand Down Expand Up @@ -135,7 +137,8 @@ protected function pruneOldJobs(array $matches, $type, OutputInterface $output)
*/
protected function pruneOlderThan($type, \DateTime $olderThan, OutputInterface $output)
{
$container = $this->getContainer();
// @TODO: move this to dependency injection.
$container = $this->getApplication()->getKernel()->getContainer();
$typeName = null;
switch ($type) {
case 'old':
Expand Down
7 changes: 4 additions & 3 deletions Command/ResetCommand.php
Expand Up @@ -2,11 +2,11 @@

namespace Dtc\QueueBundle\Command;

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 ResetCommand extends ContainerAwareCommand
class ResetCommand extends Command
{
protected function configure()
{
Expand All @@ -17,7 +17,8 @@ protected function configure()

protected function execute(InputInterface $input, OutputInterface $output)
{
$container = $this->getContainer();
// @TODO: move this to dependency injection.
$container = $this->getApplication()->getKernel()->getContainer();
$jobManager = $container->get('dtc_queue.manager.job');
$countException = $jobManager->resetExceptionJobs();
$countStalled = $jobManager->resetStalledJobs();
Expand Down
7 changes: 4 additions & 3 deletions Command/RunCommand.php
Expand Up @@ -7,14 +7,14 @@
use Dtc\QueueBundle\Run\Loop;
use Dtc\QueueBundle\Util\Util;
use Psr\Log\LoggerInterface;
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\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\HttpKernel\Kernel;

class RunCommand extends ContainerAwareCommand
class RunCommand extends Command
{
protected $loggerPrivate = false;
protected $nanoSleepOption = null;
Expand Down Expand Up @@ -101,7 +101,8 @@ protected function configure()
protected function execute(InputInterface $input, OutputInterface $output)
{
$start = microtime(true);
$container = $this->getContainer();
// @TODO: move this to dependency injection.
$container = $this->getApplication()->getKernel()->getContainer();
$loop = $container->get('dtc_queue.run.loop');
$loop->setOutput($output);
$workerName = $input->getArgument('worker-name');
Expand Down

0 comments on commit 4ff604f

Please sign in to comment.