Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 2 additions & 18 deletions src/Command/RunCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Task\TaskBundle\Command;

use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Output\OutputInterface;
Expand All @@ -33,28 +32,17 @@ class RunCommand extends Command
*/
private $scheduler;

/**
* @var EntityManagerInterface
*/
private $entityManager;

/**
* @param string $name
* @param TaskRunnerInterface $runner
* @param TaskSchedulerInterface $scheduler
* @param EntityManagerInterface $entityManager
*/
public function __construct(
$name,
TaskRunnerInterface $runner,
TaskSchedulerInterface $scheduler,
EntityManagerInterface $entityManager = null
) {
public function __construct($name, TaskRunnerInterface $runner, TaskSchedulerInterface $scheduler)
{
parent::__construct($name);

$this->runner = $runner;
$this->scheduler = $scheduler;
$this->entityManager = $entityManager;
}

/**
Expand All @@ -72,9 +60,5 @@ protected function execute(InputInterface $input, OutputInterface $output)
{
$this->runner->runTasks();
$this->scheduler->scheduleTasks();

if ($this->entityManager) {
$this->entityManager->flush();
}
}
}
3 changes: 2 additions & 1 deletion src/Command/RunHandlerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public function __construct($name, TaskHandlerFactoryInterface $handlerFactory)
*/
protected function configure()
{
$this->setDescription('Run pending tasks')
$this
->setDescription('Run pending tasks')
->addArgument('handlerClass', InputArgument::REQUIRED)
->addArgument('workload', InputArgument::OPTIONAL);
}
Expand Down
14 changes: 1 addition & 13 deletions src/Command/ScheduleTaskCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@

namespace Task\TaskBundle\Command;

use Doctrine\ORM\EntityManagerInterface;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
Expand All @@ -29,22 +28,15 @@ class ScheduleTaskCommand extends Command
*/
private $scheduler;

/**
* @var EntityManagerInterface
*/
private $entityManager;

/**
* @param string $name
* @param TaskSchedulerInterface $runner
* @param EntityManagerInterface $entityManager
*/
public function __construct($name, TaskSchedulerInterface $runner, EntityManagerInterface $entityManager = null)
public function __construct($name, TaskSchedulerInterface $runner)
{
parent::__construct($name);

$this->scheduler = $runner;
$this->entityManager = $entityManager;
}

/**
Expand Down Expand Up @@ -92,9 +84,5 @@ protected function execute(InputInterface $input, OutputInterface $output)
}

$taskBuilder->schedule();

if ($this->entityManager) {
$this->entityManager->flush();
}
}
}
2 changes: 2 additions & 0 deletions src/Entity/TaskExecutionRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public function create(TaskInterface $task, \DateTime $scheduleTime)
public function save(TaskExecutionInterface $execution)
{
$this->_em->persist($execution);
$this->_em->flush($execution);

return $this;
}
Expand All @@ -47,6 +48,7 @@ public function save(TaskExecutionInterface $execution)
public function remove(TaskExecutionInterface $execution)
{
$this->_em->remove($execution);
$this->_em->flush($execution);

return $this;
}
Expand Down
2 changes: 2 additions & 0 deletions src/Entity/TaskRepository.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ public function findByUuid($uuid)
public function save(TaskInterface $task)
{
$this->_em->persist($task);
$this->_em->flush($task);

return $this;
}
Expand All @@ -52,6 +53,7 @@ public function save(TaskInterface $task)
public function remove(TaskInterface $task)
{
$this->_em->remove($task);
$this->_em->flush($task);

return $this;
}
Expand Down